1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Use NaN-safe clip function.

This is to prevent more NaN to int conversions like in #21111.
This commit is contained in:
Vincent Rabaud
2021-12-16 11:27:37 +01:00
parent 2329cbc1a2
commit 3da17c42a4
2 changed files with 8 additions and 6 deletions
+6 -6
View File
@@ -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 )
{