-
-
Notifications
You must be signed in to change notification settings - Fork 853
Fix bug in remap #2028
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
Fix bug in remap #2028
Conversation
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.
Pull request overview
This PR fixes a bug in the remapInter function where RGB values were being zeroed when the alpha channel was zero. The fix removes alpha-based weight adjustment during pixel interpolation, preserving RGB values while still allowing alpha masking.
Key Changes:
- Removed the conditional alpha weight multiplication for RGBAfColor pixels during area interpolation
- This ensures RGB values are preserved in the weighted average regardless of alpha values
- Alpha channel itself will still be averaged, correctly indicating masking when all source pixels have alpha=0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const P & pix = source(by, bx); | ||
| double weight = yocc * xocc; | ||
|
|
||
| if constexpr (std::is_same<P, RGBAfColor>()) | ||
| { | ||
| weight *= pix.a(); | ||
| } | ||
|
|
||
| sum += pix * weight; | ||
| wsum += weight; |
Copilot
AI
Dec 2, 2025
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.
This bug fix lacks test coverage. The image module has comprehensive test files (image_test.cpp, filtering_test.cpp, resampling_test.cpp), but there are no tests for the remap functionality. Consider adding a test case that verifies:
- RGB values are preserved when alpha=0 (the bug being fixed)
- The weighted averaging still works correctly for downsampling
- Alpha channel handling is correct for various input scenarios
875c761 to
dc3246a
Compare
Remap was zeroing rgb values when alpha was zero. We want to keep the masked values but only mask it with alpha = 0.