Mercurial > hg > orthanc
diff OrthancFramework/Sources/Images/ImageProcessing.cpp @ 4780:ebb801d44e06
optimization in ImageProcessing::ShiftScale()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Aug 2021 12:13:05 +0200 |
parents | f9eda86f9045 |
children | 7053502fbf97 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/Images/ImageProcessing.cpp Mon Aug 30 11:51:56 2021 +0200 +++ b/OrthancFramework/Sources/Images/ImageProcessing.cpp Mon Aug 30 12:13:05 2021 +0200 @@ -1405,6 +1405,14 @@ } + static bool IsIdentityRescaling(float offset, + float scaling) + { + return (std::abs(offset) <= 10.0f * std::numeric_limits<float>::epsilon() && + std::abs(scaling - 1.0f) <= 10.0f * std::numeric_limits<float>::epsilon()); + } + + void ImageProcessing::ShiftScale2(ImageAccessor& image, float offset, float scaling, @@ -1413,6 +1421,11 @@ // We compute "a * x + b" const float a = scaling; const float b = offset; + + if (IsIdentityRescaling(offset, scaling)) + { + return; + } switch (image.GetFormat()) { @@ -1477,6 +1490,13 @@ const float a = scaling; const float b = offset; + if (target.GetFormat() == source.GetFormat() && + IsIdentityRescaling(offset, scaling)) + { + Copy(target, source); + return; + } + switch (target.GetFormat()) { case PixelFormat_Grayscale8: