changeset 855:6d89d5a4a723 jpeg

tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Jun 2014 12:46:15 +0200
parents ff530685e46a
children 6944fc00962e
files Core/DicomFormat/DicomImageInformation.cpp UnitTestsSources/ImageProcessingTests.cpp
diffstat 2 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomImageInformation.cpp	Fri Jun 06 12:35:08 2014 +0200
+++ b/Core/DicomFormat/DicomImageInformation.cpp	Fri Jun 06 12:46:15 2014 +0200
@@ -176,13 +176,13 @@
       return true;
     }
 
-    if (GetBitsStored() >= 9 && GetBitsStored() <= 16 && GetChannelCount() == 1 && !IsSigned())
+    if (GetBitsAllocated() == 16 && GetChannelCount() == 1 && !IsSigned())
     {
       format = PixelFormat_Grayscale16;
       return true;
     }
 
-    if (GetBitsStored() >= 9 && GetBitsStored() <= 16 && GetChannelCount() == 1 && IsSigned())
+    if (GetBitsAllocated() == 16 && GetChannelCount() == 1 && IsSigned())
     {
       format = PixelFormat_SignedGrayscale16;
       return true;
--- a/UnitTestsSources/ImageProcessingTests.cpp	Fri Jun 06 12:35:08 2014 +0200
+++ b/UnitTestsSources/ImageProcessingTests.cpp	Fri Jun 06 12:46:15 2014 +0200
@@ -33,12 +33,46 @@
 #include "PrecompiledHeadersUnitTests.h"
 #include "gtest/gtest.h"
 
+#include "../Core/DicomFormat/DicomImageInformation.h"
 #include "../Core/ImageFormats/ImageBuffer.h"
 #include "../Core/ImageFormats/ImageProcessing.h"
 
 using namespace Orthanc;
 
 
-TEST(ImageProcessing, Copy)
+TEST(DicomImageInformation, ExtractPixelFormat1)
 {
+  // Cardiac/MR*
+  DicomMap m;
+  m.SetValue(DICOM_TAG_ROWS, "24");
+  m.SetValue(DICOM_TAG_COLUMNS, "16");
+  m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16");
+  m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1");
+  m.SetValue(DICOM_TAG_BITS_STORED, "12");
+  m.SetValue(DICOM_TAG_HIGH_BIT, "11");
+  m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "0");
+
+  DicomImageInformation info(m);
+  PixelFormat format;
+  ASSERT_TRUE(info.ExtractPixelFormat(format));
+  ASSERT_EQ(PixelFormat_Grayscale16, format);
 }
+
+
+TEST(DicomImageInformation, ExtractPixelFormat2)
+{
+  // Delphine CT
+  DicomMap m;
+  m.SetValue(DICOM_TAG_ROWS, "24");
+  m.SetValue(DICOM_TAG_COLUMNS, "16");
+  m.SetValue(DICOM_TAG_BITS_ALLOCATED, "16");
+  m.SetValue(DICOM_TAG_SAMPLES_PER_PIXEL, "1");
+  m.SetValue(DICOM_TAG_BITS_STORED, "16");
+  m.SetValue(DICOM_TAG_HIGH_BIT, "15");
+  m.SetValue(DICOM_TAG_PIXEL_REPRESENTATION, "1");
+
+  DicomImageInformation info(m);
+  PixelFormat format;
+  ASSERT_TRUE(info.ExtractPixelFormat(format));
+  ASSERT_EQ(PixelFormat_SignedGrayscale16, format);
+}