Merge pull request #21271 from vrabaud:3.4_clip

pull/21278/head
Alexander Alekhin 3 years ago
commit cee3ec6dc4
  1. 12
      modules/imgproc/src/color_lab.cpp
  2. 2
      modules/imgproc/test/test_color.cpp

@ -2979,9 +2979,9 @@ struct RGB2Luvfloat
for( ; i < n; i++, src += scn, dst += 3 )
{
float R = src[0], G = src[1], B = src[2];
R = std::min(std::max(R, 0.f), 1.f);
G = std::min(std::max(G, 0.f), 1.f);
B = std::min(std::max(B, 0.f), 1.f);
R = clip(R);
G = clip(G);
B = clip(B);
if( gammaTab )
{
R = splineInterpolate(R*gscale, gammaTab, GAMMA_TAB_SIZE);
@ -3205,9 +3205,9 @@ struct Luv2RGBfloat
float G = X*C3 + Y*C4 + Z*C5;
float B = X*C6 + Y*C7 + Z*C8;
R = std::min(std::max(R, 0.f), 1.f);
G = std::min(std::max(G, 0.f), 1.f);
B = std::min(std::max(B, 0.f), 1.f);
R = clip(R);
G = clip(G);
B = clip(B);
if( gammaTab )
{

@ -3203,6 +3203,8 @@ TEST(ImgProc_RGB2Lab, NaN_21111)
src(0, 1) = src(0, 28) = src(0, 82) = src(0, 109) = cv::Vec3f(0, kNaN, 0);
src(0, 2) = src(0, 29) = src(0, 83) = src(0, 110) = cv::Vec3f(kNaN, 0, 0);
EXPECT_NO_THROW(cvtColor(src, dst, COLOR_RGB2Lab));
EXPECT_NO_THROW(cvtColor(src, dst, COLOR_RGB2Luv));
EXPECT_NO_THROW(cvtColor(src, dst, COLOR_Luv2RGB));
#if 0 // no NaN propagation guarantee
for (int i = 0; i < 20; ++i)

Loading…
Cancel
Save