changeset 1637:d569effcd433

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Nov 2020 16:25:20 +0100
parents d1e0b08b809d
children 754ef576d945
files OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp OrthancStone/Sources/Toolbox/DicomInstanceParameters.h
diffstat 2 files changed, 44 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp	Tue Nov 10 16:20:22 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp	Tue Nov 10 16:25:20 2020 +0100
@@ -138,9 +138,6 @@
       }
     }
 
-    isColor_ = (imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 &&
-                imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2);
-
     if (dicom.ParseDouble(rescaleIntercept_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) &&
         dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE))
     {
@@ -194,33 +191,6 @@
       defaultWindowingWidth_  = 0;
     }
 
-    expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16;  // Rough guess
-    
-    if (sopClassUid_ == SopClassUid_RTDose)
-    {
-      switch (imageInformation_.GetBitsStored())
-      {
-        case 16:
-          expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16;
-          break;
-
-        case 32:
-          expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale32;
-          break;
-
-        default:
-          break;
-      } 
-    }
-    else if (isColor_)
-    {
-      expectedPixelFormat_ = Orthanc::PixelFormat_RGB24;
-    }
-    else if (imageInformation_.IsSigned())
-    {
-      expectedPixelFormat_ = Orthanc::PixelFormat_SignedGrayscale16;
-    }
-
     // This computes the "IndexInSeries" metadata from Orthanc (check
     // out "Orthanc::ServerIndex::Store()")
     hasIndexInSeries_ = (
@@ -272,6 +242,17 @@
             distance <= data_.sliceThickness_ / 2.0);
   }
 
+
+  bool DicomInstanceParameters::IsColor() const
+  {
+    Orthanc::PhotometricInterpretation photometric =
+      data_.imageInformation_.GetPhotometricInterpretation();
+    
+    return (photometric != Orthanc::PhotometricInterpretation_Monochrome1 &&
+            photometric != Orthanc::PhotometricInterpretation_Monochrome2);
+  }
+
+
   void DicomInstanceParameters::ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image,
                                                            bool useDouble) const
   {
@@ -348,6 +329,37 @@
   }
 
 
+  Orthanc::PixelFormat DicomInstanceParameters::GetExpectedPixelFormat() const
+  {
+    if (GetSopClassUid() == SopClassUid_RTDose)
+    {
+      switch (GetImageInformation().GetBitsStored())
+      {
+        case 16:
+          return Orthanc::PixelFormat_Grayscale16;
+
+        case 32:
+          return Orthanc::PixelFormat_Grayscale32;
+
+        default:
+          return Orthanc::PixelFormat_Grayscale16;  // Rough guess
+      } 
+    }
+    else if (IsColor())
+    {
+      return Orthanc::PixelFormat_RGB24;
+    }
+    else if (GetImageInformation().IsSigned())
+    {
+      return Orthanc::PixelFormat_SignedGrayscale16;
+    }
+    else
+    {
+      return Orthanc::PixelFormat_Grayscale16;  // Rough guess
+    }
+  }
+
+
   float DicomInstanceParameters::GetDefaultWindowingCenter() const
   {
     if (data_.hasDefaultWindowing_)
--- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.h	Tue Nov 10 16:20:22 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.h	Tue Nov 10 16:25:20 2020 +0100
@@ -53,14 +53,12 @@
       double                            pixelSpacingY_;
       CoordinateSystem3D                geometry_;
       Vector                            frameOffsets_;
-      bool                              isColor_;   // TODO REMOVE
       bool                              hasRescale_;
       double                            rescaleIntercept_;
       double                            rescaleSlope_;
       bool                              hasDefaultWindowing_;
       float                             defaultWindowingCenter_;
       float                             defaultWindowingWidth_;
-      Orthanc::PixelFormat              expectedPixelFormat_;  // TODO REMOVE
       bool                              hasIndexInSeries_;
       unsigned int                      indexInSeries_;
       std::string                       doseUnits_;
@@ -166,10 +164,7 @@
     bool IsPlaneWithinSlice(unsigned int frame,
                             const CoordinateSystem3D& plane) const;
 
-    bool IsColor() const
-    {
-      return data_.isColor_;
-    }
+    bool IsColor() const;
 
     bool HasRescale() const
     {
@@ -189,10 +184,7 @@
 
     float GetDefaultWindowingWidth() const;
 
-    Orthanc::PixelFormat GetExpectedPixelFormat() const
-    {
-      return data_.expectedPixelFormat_;
-    }
+    Orthanc::PixelFormat GetExpectedPixelFormat() const;
 
     Orthanc::ImageAccessor* ConvertToFloat(const Orthanc::ImageAccessor& pixelData) const;