# HG changeset patch # User Sebastien Jodogne # Date 1566913751 -7200 # Node ID ce9e8f6b4dfff9476eb6195cd65b39ca75e015b6 # Parent df5c69b5c9c3bebe316df2c3c573c44f07f18ca8 use whole dynamics if no windowing is provided diff -r df5c69b5c9c3 -r ce9e8f6b4dff Plugin/WadoRsRetrieveRendered.cpp --- a/Plugin/WadoRsRetrieveRendered.cpp Tue Aug 27 15:32:47 2019 +0200 +++ b/Plugin/WadoRsRetrieveRendered.cpp Tue Aug 27 15:49:11 2019 +0200 @@ -34,6 +34,7 @@ { enum WindowingMode { + WindowingMode_WholeDynamics, WindowingMode_Linear, WindowingMode_LinearExact, WindowingMode_Sigmoid @@ -124,7 +125,7 @@ quality_(90), // Default quality for JPEG previews (the same as in Orthanc core) windowCenter_(128), windowWidth_(256), - windowingMode_(WindowingMode_Linear), + windowingMode_(WindowingMode_WholeDynamics), rescaleSlope_(1), rescaleIntercept_(0) { @@ -503,7 +504,29 @@ const float exactXMax = (c + w / 2.0f); const float exactYScaling = (ymax - ymin) / w; const float exactYOffset = (-c * ymax + ymin * (c + w)) / w; - + + + float minValue = std::numeric_limits::infinity(); + float maxValue = -std::numeric_limits::infinity(); + float wholeDynamicsScale = 1; + + if (mode == WindowingMode_WholeDynamics) + { + for (unsigned int y = 0; y < height; y++) + { + for (unsigned int x = 0; x < width; x++) + { + float a = Orthanc::ImageTraits::GetFloatPixel(source, x, y); + minValue = std::min(minValue, a); + maxValue = std::max(maxValue, a); + } + } + + minValue = rescaleSlope * minValue + rescaleIntercept; + maxValue = rescaleSlope * maxValue + rescaleIntercept; + wholeDynamicsScale = 255.0f / (maxValue - minValue); + } + for (unsigned int y = 0; y < height; y++) { @@ -516,6 +539,10 @@ switch (mode) { + case WindowingMode_WholeDynamics: + b = (a - minValue) * wholeDynamicsScale; + break; + case WindowingMode_Linear: { if (a <= linearXMin)