-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Fix H clamping for very small negative values. #21063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -955,14 +955,9 @@ struct HLS2RGB_f | |||
float p1 = 2*l - p2; | |||
|
|||
h *= hscale; | |||
if( h < 0 ) | |||
do h += 6; while( h < 0 ); | |||
else if( h >= 6 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we can't replace else if
=> if
+ add comment to avoid replacing this back.
Proposed expression work for SIMD code (with comparison through v_select) but expression still may lead to crash of this code (with array indexes, without strong CV_Assert()
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can indeed remove the else, I just wanted the code to be like SIMD for consistency and also thought that the while loop might be an overkill if h is too big.
1219c93
to
4b3375d
Compare
Sorry I actually did not get: in the end, do you want the simple solution where I just remove the else, or the one that copies the SIMD code and that does not have two while loops ? |
I prefer minimal changes (with removal of the else). |
0465253
to
b0fe829
Compare
ok, done. |
b0fe829
to
1e68bc8
Compare
1e68bc8
to
d7b51e3
Compare
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.
d7b51e3
to
d4741ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
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.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request