Mercurial > hg > orthanc
diff Core/Images/ImageProcessing.cpp @ 3690:a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Feb 2020 13:57:43 +0100 |
parents | 3971ec6b1f72 |
children | 2a170a8f1faf |
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp Tue Feb 25 11:07:56 2020 +0100 +++ b/Core/Images/ImageProcessing.cpp Tue Feb 25 13:57:43 2020 +0100 @@ -1430,6 +1430,46 @@ } + 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; + + switch (target.GetFormat()) + { + case PixelFormat_Grayscale8: + + switch (source.GetFormat()) + { + case PixelFormat_Float32: + if (useRound) + { + ShiftScaleInternal<uint8_t, float, true, false>( + target, source, a, b, std::numeric_limits<uint8_t>::min()); + } + else + { + ShiftScaleInternal<uint8_t, float, false, false>( + target, source, a, b, std::numeric_limits<uint8_t>::min()); + } + return; + + default: + throw OrthancException(ErrorCode_NotImplemented); + } + + default: + throw OrthancException(ErrorCode_NotImplemented); + } + } + + void ImageProcessing::Invert(ImageAccessor& image, int64_t maxValue) { const unsigned int width = image.GetWidth();