# HG changeset patch # User Sebastien Jodogne # Date 1592845485 -7200 # Node ID 259c33759937456a6ffa44be4c784da304caa425 # Parent c5c41f66ec294cd93d951c0b8769cfc19387b29c# Parent f18eaade61538527ad59135e591b2ed64b12b65c integration mainline->framework diff -r c5c41f66ec29 -r 259c33759937 OrthancFramework/Sources/Images/ImageProcessing.cpp --- 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 va; + va.push_back(0); + va.push_back(-10); + va.push_back(5); + + std::vector vb; + vb.push_back(0); + vb.push_back(-42); + vb.push_back(42); + + Image source(PixelFormat_Float32, 1, 1, false); + ImageTraits::SetFloatPixel(source, 10, 0, 0); + + for (std::vector::const_iterator a = va.begin(); a != va.end(); ++a) + { + for (std::vector::const_iterator b = vb.begin(); b != vb.end(); ++b) + { + Image target(PixelFormat_Float32, 1, 1, false); + + ImageProcessing::Copy(target, source); + ImageProcessing::ShiftScale2(target, *b, *a, false); + ASSERT_FLOAT_EQ((*a) * 10.0f + (*b), + ImageTraits::GetFloatPixel(target, 0, 0)); + + ImageProcessing::Copy(target, source); + ImageProcessing::ShiftScale(target, *b, *a, false); + ASSERT_FLOAT_EQ((*a) * (10.0f + (*b)), + ImageTraits::GetFloatPixel(target, 0, 0)); + } + } +}