# HG changeset patch # User Sebastien Jodogne # Date 1445417497 -7200 # Node ID 02ccb1677e91ffba2d18929c02b5b263a667de41 # Parent c44ab3266343bb639fd335f500c11647e32d5a24 Support of images encoded using LUT (lookup tables) diff -r c44ab3266343 -r 02ccb1677e91 NEWS --- 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) diff -r c44ab3266343 -r 02ccb1677e91 Plugin/ParsedDicomImage.cpp --- 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 +#include #include #include #include @@ -43,6 +44,7 @@ OrthancPluginContext* context_; std::string instanceId_; gdcm::ImageReader reader_; + std::auto_ptr lut_; std::auto_ptr photometric_; std::auto_ptr 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();