Skip to content

prevent negative hue#26

Merged
bghira merged 1 commit into
mainfrom
bugfix/negative-hue
Apr 6, 2026
Merged

prevent negative hue#26
bghira merged 1 commit into
mainfrom
bugfix/negative-hue

Conversation

@bghira
Copy link
Copy Markdown
Owner

@bghira bghira commented Apr 6, 2026

This pull request addresses a subtle edge case in the RGB-to-HSV color conversion logic and adds a corresponding test to ensure correct behavior. The main focus is on handling hue values that would otherwise be negative, ensuring they wrap correctly as in OpenCV.

Color conversion bug fix:

  • Updated the hue calculation in the cvtcolor module to use .rem_euclid(6.0) instead of % 6.0, ensuring that negative hue values are wrapped correctly rather than producing unexpected results. This change aligns the behavior with OpenCV's implementation.

Testing improvements:

  • Added a new test case (test_rgb_to_hsv_wraps_negative_red_sector_hues) in cv_compat_tests to verify that the hue wraps properly for RGB values in the red sector where g < b, matching OpenCV's expected output.

@bghira bghira merged commit 62f1d6d into main Apr 6, 2026
10 checks passed
@bghira bghira deleted the bugfix/negative-hue branch April 6, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant