Mercurial > hg > orthanc-dicomweb
changeset 453:1351ca908f9d
Fix ".../rendered" on MONOCHROME1 images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 Jun 2020 17:33:19 +0200 |
parents | 36d04c9586c1 |
children | 59ecea46e2ff |
files | NEWS Plugin/WadoRsRetrieveRendered.cpp |
diffstat | 2 files changed, 24 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Mon Jun 22 16:17:31 2020 +0200 +++ b/NEWS Wed Jun 24 17:33:19 2020 +0200 @@ -3,6 +3,7 @@ * Support transcoding in WADO-RS RetrieveStudy, RetrieveSeries and RetrieveInstance * Support of dynamic linking against the Orthanc framework library +* Fix ".../rendered" on MONOCHROME1 images Version 1.2 (2020-05-26)
--- a/Plugin/WadoRsRetrieveRendered.cpp Mon Jun 22 16:17:31 2020 +0200 +++ b/Plugin/WadoRsRetrieveRendered.cpp Wed Jun 24 17:33:19 2020 +0200 @@ -598,7 +598,8 @@ static void ApplyRendering(Orthanc::ImageAccessor& target, const Orthanc::ImageAccessor& source, - const RenderingParameters& parameters) + const RenderingParameters& parameters, + bool invert) { Orthanc::ImageProcessing::Set(target, 0); @@ -661,6 +662,10 @@ Orthanc::ImageProcessing::FlipY(scaled); } + if (invert) + { + Orthanc::ImageProcessing::Invert(scaled); + } // TODO => Replace what follows with a call to "Orthanc::ImageProcessing::FitSize()" @@ -697,6 +702,7 @@ { static const char* const RESCALE_INTERCEPT = "0028,1052"; static const char* const RESCALE_SLOPE = "0028,1053"; + static const char* const PHOTOMETRIC_INTERPRETATION = "0028,0004"; Orthanc::MimeType mime = Orthanc::MimeType_Jpeg; // This is the default in DICOMweb @@ -795,8 +801,22 @@ Orthanc::Image target(targetFormat, parameters.GetTargetWidth(source.GetWidth()), parameters.GetTargetHeight(source.GetHeight()), false); - ApplyRendering(target, source, parameters); - + // New in 1.3: Fix for MONOCHROME1 images + bool invert = false; + if (target.GetFormat() == Orthanc::PixelFormat_Grayscale8 && + tags.isMember(PHOTOMETRIC_INTERPRETATION) && + tags[PHOTOMETRIC_INTERPRETATION].type() == Json::stringValue) + { + std::string s = tags[PHOTOMETRIC_INTERPRETATION].asString(); + Orthanc::Toolbox::StripSpaces(s); + if (s == "MONOCHROME1") + { + invert = true; + } + } + + ApplyRendering(target, source, parameters, invert); + switch (mime) { case Orthanc::MimeType_Png: