Mercurial > hg > orthanc
changeset 1940:5514d37176b4
PatternUint16
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Mar 2016 11:08:07 +0100 |
parents | d80a4fe8ffcc |
children | d7b176f7dd1b |
files | UnitTestsSources/FromDcmtkTests.cpp UnitTestsSources/UnitTestsMain.cpp |
diffstat | 2 files changed, 41 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/UnitTestsSources/FromDcmtkTests.cpp Fri Mar 25 10:48:12 2016 +0100 +++ b/UnitTestsSources/FromDcmtkTests.cpp Fri Mar 25 11:08:07 2016 +0100 @@ -42,9 +42,12 @@ #include "../Core/Images/PngReader.h" #include "../Core/Images/PngWriter.h" #include "../Core/Images/Image.h" +#include "../Core/Images/ImageProcessing.h" #include "../Core/Uuid.h" +#include "../Core/Endianness.h" #include "../Resources/EncodingTests.h" #include "../OrthancServer/DicomProtocol/DicomFindAnswers.h" +#include "../OrthancServer/Internals/DicomImageDecoder.h" #include <dcmtk/dcmdata/dcelem.h> @@ -765,8 +768,10 @@ -TEST(TestImages, DISABLED_PatternUint16) +TEST(TestImages, PatternUint16) { + static const char* PATH = "UnitTestsResults/PatternGrayscale16.dcm"; + Orthanc::Image image(Orthanc::PixelFormat_Grayscale16, 256, 256); uint16_t v = 0; @@ -775,18 +780,41 @@ uint16_t *p = reinterpret_cast<uint16_t*>(image.GetRow(y)); for (int x = 0; x < 256; x++, v++, p++) { - *p = v; + *p = htole16(v); // Orthanc uses Little-Endian transfer syntax to encode images } } - ParsedDicomFile f(true); - f.Replace(DICOM_TAG_PATIENT_ID, "ORTHANC"); - f.Replace(DICOM_TAG_PATIENT_NAME, "Orthanc"); - f.Replace(DICOM_TAG_STUDY_DESCRIPTION, "Patterns"); - f.Replace(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale16"); - f.EmbedImage(image); + Orthanc::ImageAccessor r = image.GetRegion(32, 32, 64, 192); + Orthanc::ImageProcessing::Set(r, 0); + r = image.GetRegion(160, 32, 64, 192); + Orthanc::ImageProcessing::Set(r, 65535); + + { + ParsedDicomFile f(true); + f.Replace(DICOM_TAG_PATIENT_ID, "ORTHANC"); + f.Replace(DICOM_TAG_PATIENT_NAME, "Orthanc"); + f.Replace(DICOM_TAG_STUDY_DESCRIPTION, "Patterns"); + f.Replace(DICOM_TAG_SERIES_DESCRIPTION, "Grayscale16"); + f.EmbedImage(image); + + f.SaveToFile(PATH); + } - f.SaveToFile("PatternGrayscale16.dcm"); + { + std::string s; + Orthanc::Toolbox::ReadFile(s, PATH); + Orthanc::ParsedDicomFile f(s); + + std::auto_ptr<Orthanc::ImageAccessor> decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); + ASSERT_EQ(256, decoded->GetWidth()); + ASSERT_EQ(256, decoded->GetHeight()); + ASSERT_EQ(Orthanc::PixelFormat_Grayscale16, decoded->GetFormat()); + + for (int y = 0; y < 256; y++) + { + const void* a = image.GetConstRow(y); + const void* b = decoded->GetConstRow(y); + ASSERT_EQ(0, memcmp(a, b, 512)); + } + } } - -
--- a/UnitTestsSources/UnitTestsMain.cpp Fri Mar 25 10:48:12 2016 +0100 +++ b/UnitTestsSources/UnitTestsMain.cpp Fri Mar 25 11:08:07 2016 +0100 @@ -839,8 +839,8 @@ TEST(Toolbox, EndiannessConversions64) { - const uint64_t v = 0xff01020304050607LLu; - const uint64_t r = 0x07060504030201ffLLu; + const uint64_t v = 0xff01020304050607LLU; + const uint64_t r = 0x07060504030201ffLLU; ASSERT_EQ64(v, be64toh(htobe64(v))); ASSERT_EQ64(v, le64toh(htole64(v))); ASSERT_NE64(v, be64toh(htole64(v)));