Skip to content
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 box blur symmetry & simplify code #3631

Merged
merged 1 commit into from
Dec 13, 2023
Merged

Conversation

rmn20
Copy link
Contributor

@rmn20 rmn20 commented Dec 12, 2023

Previous version of box blur kernel was asymmetrical, because the leftmost and topmost pixels were subtracted from the average values too early, causing the image to offset by GAUSSIAN_BLUR_ITERATIONS pixels after blurring. You can see this at the rightmost and bottommost borders of the image. This commit fixes this bug.

Original image Old box blur Fixed box blur
image image image

Image is also a bit more blurry now since the blur kernel is now 1 pixel wider.
PS. Perhaps GAUSSIAN_BLUR_ITERATIONS could be a function argument rather than a predefined value?

@rmn20 rmn20 marked this pull request as ready for review December 12, 2023 23:22
@raysan5 raysan5 merged commit 222f6f7 into raysan5:master Dec 13, 2023
@raysan5
Copy link
Owner

raysan5 commented Dec 13, 2023

@rmn20 Nice! Great improvement! Actually I didn't notice the issue with previous implementation, but not it looks way better! Thanks!

denysmaistruk pushed a commit to denysmaistruk/raylib that referenced this pull request Dec 14, 2023
@rmn20
Copy link
Contributor Author

rmn20 commented Dec 22, 2023

@raysan5 You can see the offset issue with previous implementation much more obviously, if you apply box blur several times.
For example, here I've applied box blur with radius 1 three times:

Original image Old box blur Fixed box blur
image image image

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.

2 participants