mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Fix H clamping for very small negative values.
In case of very small negative h (e.g. -1e-40), with the current implementation, you will go through the first condition and end up with h = 6.f, and will miss the second condition.
This commit is contained in:
parent
585484cb06
commit
d4741eece1
@ -955,12 +955,11 @@ struct HLS2RGB_f
|
||||
float p1 = 2*l - p2;
|
||||
|
||||
h *= hscale;
|
||||
if( h < 0 )
|
||||
do h += 6; while( h < 0 );
|
||||
else if( h >= 6 )
|
||||
do h -= 6; while( h >= 6 );
|
||||
// We need both loops to clamp (e.g. for h == -1e-40).
|
||||
while( h < 0 ) h += 6;
|
||||
while( h >= 6 ) h -= 6;
|
||||
|
||||
assert( 0 <= h && h < 6 );
|
||||
CV_DbgAssert( 0 <= h && h < 6 );
|
||||
sector = cvFloor(h);
|
||||
h -= sector;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user