corrected un-initialized variable in RGBtoHSV

This commit is contained in:
Paolo Cignoni 2010-06-23 14:23:32 +00:00
parent ad0a3daf01
commit 04694569cf
1 changed files with 5 additions and 10 deletions

View File

@ -1463,11 +1463,8 @@ public:
static void RGBtoHSV(double R, double G, double B, double &H, double &S, double &V)
{
double v = std::min(R, G);
double v_min = std::min(v, B); // Min value of RGB
double v2 = std::max(R, G);
double v_max = std::max(v2, B); // Max value of RGB
double v_min = std::min(std::min(R, G), B); // Min value of RGB
double v_max = std::max(std::max(R, G), B); // Max value of RGB
double delta = v_max - v_min; //Delta RGB value
@ -1492,12 +1489,10 @@ public:
H = (1.0 / 3.0) + deltaR - deltaB;
else if (B == v_max)
H = (2.0 / 3.0) + deltaG - deltaR;
else H = 0; // this final branch should never happen...
if ( H < 0 )
H += 1.0;
if ( H > 1 )
H -= 1.0;
if ( H < 0 ) H += 1.0;
if ( H > 1 ) H -= 1.0;
}
}