Mercurial > hg > orthanc
diff OrthancFramework/Sources/Images/ImageProcessing.cpp @ 4081:259c33759937 framework
integration mainline->framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Jun 2020 19:04:45 +0200 |
parents | Core/Images/ImageProcessing.cpp@f18eaade6153 Core/Images/ImageProcessing.cpp@d6362b2c4b61 |
children | 26efd0404d97 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/Images/ImageProcessing.cpp Mon Jun 22 15:10:03 2020 +0200 +++ b/OrthancFramework/Sources/Images/ImageProcessing.cpp Mon Jun 22 19:04:45 2020 +0200 @@ -393,7 +393,8 @@ // Computes "a * x + b" at each pixel => Note that this is not the - // same convention as in "ShiftScale()" + // same convention as in "ShiftScale()", but it is the convention of + // "ShiftScale2()" template <typename TargetType, typename SourceType, bool UseRound, @@ -1375,15 +1376,14 @@ } - void ImageProcessing::ShiftScale(ImageAccessor& image, - float offset, - float scaling, - bool useRound) + void ImageProcessing::ShiftScale2(ImageAccessor& image, + float offset, + float scaling, + bool useRound) { - // Rewrite "(x + offset) * scaling" as "a * x + b" - + // We compute "a * x + b" const float a = scaling; - const float b = offset * scaling; + const float b = offset; switch (image.GetFormat()) { @@ -1438,16 +1438,15 @@ } - void ImageProcessing::ShiftScale(ImageAccessor& target, - const ImageAccessor& source, - float offset, - float scaling, - bool useRound) + void ImageProcessing::ShiftScale2(ImageAccessor& target, + const ImageAccessor& source, + float offset, + float scaling, + bool useRound) { - // Rewrite "(x + offset) * scaling" as "a * x + b" - + // We compute "a * x + b" const float a = scaling; - const float b = offset * scaling; + const float b = offset; switch (target.GetFormat()) { @@ -1478,6 +1477,34 @@ } + void ImageProcessing::ShiftScale(ImageAccessor& image, + float offset, + float scaling, + bool useRound) + { + // Rewrite "(x + offset) * scaling" as "a * x + b" + + const float a = scaling; + const float b = offset * scaling; + ShiftScale2(image, b, a, useRound); + } + + + void ImageProcessing::ShiftScale(ImageAccessor& target, + const ImageAccessor& source, + float offset, + float scaling, + bool useRound) + { + // Rewrite "(x + offset) * scaling" as "a * x + b" + + const float a = scaling; + const float b = offset * scaling; + ShiftScale2(target, source, b, a, useRound); + } + + + void ImageProcessing::Invert(ImageAccessor& image, int64_t maxValue) { const unsigned int width = image.GetWidth();