# HG changeset patch # User Sebastien Jodogne # Date 1574087076 -3600 # Node ID acb399643945584b6653a1bebb773b4509679709 # Parent e3eaadcb314a0011dd75b80879e786b5221631a6 DicomInstanceParameters::ApplyRescale() diff -r e3eaadcb314a -r acb399643945 Framework/Toolbox/DicomInstanceParameters.cpp --- a/Framework/Toolbox/DicomInstanceParameters.cpp Sun Nov 17 11:37:47 2019 +0100 +++ b/Framework/Toolbox/DicomInstanceParameters.cpp Mon Nov 18 15:24:36 2019 +0100 @@ -265,7 +265,7 @@ void DicomInstanceParameters::Data::ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image, - bool useDouble) const + bool useDouble) const { if (image.GetFormat() != Orthanc::PixelFormat_Float32) { @@ -455,4 +455,19 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } } + + + double DicomInstanceParameters::Data::ApplyRescale(double value) const + { + double factor = doseGridScaling_; + double offset = 0.0; + + if (hasRescale_) + { + factor *= rescaleSlope_; + offset = rescaleIntercept_; + } + + return (value * factor + offset); + } } diff -r e3eaadcb314a -r acb399643945 Framework/Toolbox/DicomInstanceParameters.h --- a/Framework/Toolbox/DicomInstanceParameters.h Sun Nov 17 11:37:47 2019 +0100 +++ b/Framework/Toolbox/DicomInstanceParameters.h Mon Nov 18 15:24:36 2019 +0100 @@ -71,8 +71,10 @@ bool IsPlaneWithinSlice(unsigned int frame, const CoordinateSystem3D& plane) const; - void ApplyRescaleAndDoseScaling( - Orthanc::ImageAccessor& image, bool useDouble) const; + void ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image, + bool useDouble) const; + + double ApplyRescale(double value) const; }; @@ -211,5 +213,10 @@ { return data_.doseGridScaling_; } + + double ApplyRescale(double value) const + { + return data_.ApplyRescale(value); + } }; }