changeset 87:02ccb1677e91

Support of images encoded using LUT (lookup tables)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 21 Oct 2015 10:51:37 +0200
parents c44ab3266343
children cb277a708b48
files NEWS Plugin/ParsedDicomImage.cpp
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Oct 20 17:40:14 2015 +0200
+++ b/NEWS	Wed Oct 21 10:51:37 2015 +0200
@@ -3,9 +3,10 @@
 
 => Minimum SDK version: 0.9.4 <=
 
+* Support of images encoded using LUT (lookup tables)
+* Use Orthanc's primitives for PNG and JPEG
 * Fix for old versions of jQuery
 * Fix possible deadlock with other plugins in OnChangeCallback()
-* Use Orthanc's primitives for PNG and JPEG
 
 
 Version 1.2 (2015-08-02)
--- a/Plugin/ParsedDicomImage.cpp	Tue Oct 20 17:40:14 2015 +0200
+++ b/Plugin/ParsedDicomImage.cpp	Wed Oct 21 10:51:37 2015 +0200
@@ -27,6 +27,7 @@
 #include "ViewerToolbox.h"
 
 #include <gdcmImageReader.h>
+#include <gdcmImageApplyLookupTable.h>
 #include <gdcmImageChangePlanarConfiguration.h>
 #include <gdcmImageChangePhotometricInterpretation.h>
 #include <boost/lexical_cast.hpp>
@@ -43,6 +44,7 @@
     OrthancPluginContext* context_;
     std::string instanceId_;
     gdcm::ImageReader reader_;
+    std::auto_ptr<gdcm::ImageApplyLookupTable> lut_;
     std::auto_ptr<gdcm::ImageChangePhotometricInterpretation> photometric_;
     std::auto_ptr<gdcm::ImageChangePlanarConfiguration> interleaved_;
     std::string decoded_;
@@ -51,10 +53,21 @@
 
     bool DecodeUsingGdcm()
     {
-      // Change photometric interpretation, if required
+      // Change photometric interpretation or apply LUT, if required
       {
         const gdcm::Image& image = GetImage();
-        if (image.GetPixelFormat().GetSamplesPerPixel() == 1)
+        if (image.GetPixelFormat().GetSamplesPerPixel() == 1 &&
+            image.GetPhotometricInterpretation() == gdcm::PhotometricInterpretation::PALETTE_COLOR)
+        {
+          lut_.reset(new gdcm::ImageApplyLookupTable());
+          lut_->SetInput(image);
+          if (!lut_->Apply())
+          {
+            OrthancPluginLogWarning(context_, "GDCM cannot apply the lookup table");
+            return false;
+          }
+        }
+        else if (image.GetPixelFormat().GetSamplesPerPixel() == 1)
         {
           if (image.GetPhotometricInterpretation() != gdcm::PhotometricInterpretation::MONOCHROME1 &&
               image.GetPhotometricInterpretation() != gdcm::PhotometricInterpretation::MONOCHROME2)
@@ -173,6 +186,7 @@
       }
 
       // GDCM cannot decode this image, try and use Orthanc built-in functions
+      lut_.reset();
       photometric_.reset();
       interleaved_.reset();
       decoded_.clear();
@@ -218,6 +232,11 @@
         return interleaved_->GetOutput();
       }
 
+      if (lut_.get() != NULL)
+      {
+        return lut_->GetOutput();
+      }
+
       if (photometric_.get() != NULL)
       {
         return photometric_->GetOutput();