changeset 1883:fba6e550e0ee

apply rescale slope/intercept in rendering plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jan 2022 18:26:05 +0100
parents 4e80b8afd0da
children 0c6923982fdd
files RenderingPlugin/Sources/Plugin.cpp
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/RenderingPlugin/Sources/Plugin.cpp	Wed Jan 12 18:02:24 2022 +0100
+++ b/RenderingPlugin/Sources/Plugin.cpp	Wed Jan 12 18:26:05 2022 +0100
@@ -23,6 +23,7 @@
 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 
 #include "../../OrthancStone/Sources/Toolbox/AffineTransform2D.h"
+#include "../../OrthancStone/Sources/Toolbox/DicomInstanceParameters.h"
 
 #include <EmbeddedResources.h>
 
@@ -61,7 +62,20 @@
                              const OrthancPluginHttpRequest* request)
 {
   // TODO: Parameters in GET
-  // TODO: Rescale slope/intercept
+
+  OrthancPlugins::MemoryBuffer tags;
+  if (!tags.RestApiGet("/instances/" + std::string(request->groups[0]) + "/tags", false))
+  {
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem);
+  }
+
+  Json::Value json;
+  tags.ToJson(json);
+
+  Orthanc::DicomMap m;
+  m.FromDicomAsJson(json);
+
+  OrthancStone::DicomInstanceParameters parameters(m);
   
   OrthancPlugins::MemoryBuffer dicom;
   dicom.GetDicomInstance(request->groups[0]);
@@ -103,11 +117,11 @@
   }
   else
   {
-    Orthanc::Image converted(Orthanc::PixelFormat_Float32, image.GetWidth(), image.GetHeight(), false);
-    Orthanc::ImageProcessing::Convert(converted, source);
+    std::unique_ptr<Orthanc::ImageAccessor> converted(parameters.ConvertToFloat(source));
 
-    modified.reset(new Orthanc::Image(converted.GetFormat(), converted.GetWidth(), converted.GetHeight(), false));
-    t.Apply(*modified, converted, OrthancStone::ImageInterpolation_Bilinear, true);
+    assert(converted.get() != NULL);
+    modified.reset(new Orthanc::Image(converted->GetFormat(), converted->GetWidth(), converted->GetHeight(), false));
+    t.Apply(*modified, *converted, OrthancStone::ImageInterpolation_Bilinear, true);
   }
 
   assert(modified.get() != NULL);