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: Normalize Gaussian 2D kernel. #725

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

cgringmuth
Copy link
Contributor

@cgringmuth cgringmuth commented Feb 1, 2023

Description

Gaussian kernel does not sum up to 1 which leads to darkening of image after convolution.

I also rewrote a little the code. Especially const float value = static_cast<float>(nominator / denominator); which should be of type T in my opinion. Otherwise value is always float, independent of T.

References

When converting the Gaussian’s continuous values into the discrete values needed for a kernel, the sum of the values will be different from 1. This will cause a darkening or brightening of the image. To remedy this, the values can be normalized by dividing each term in the kernel by the sum of all terms in the kernel.

from wiki

Tasklist

  • Add test case(s)
  • Ensure all CI builds pass
  • Review and approve

Copy link
Member

@mloskot mloskot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made one request related to, I think, unnecessary re-formatting.

include/boost/gil/image_processing/numeric.hpp Outdated Show resolved Hide resolved
Copy link
Member

@mloskot mloskot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mloskot mloskot added the cat/bug But reports and bug fixes label Feb 7, 2023
@mloskot mloskot added this to the Boost 1.81+ milestone Feb 7, 2023
@mloskot mloskot merged commit d6e67f3 into boostorg:develop Feb 7, 2023
@cgringmuth cgringmuth deleted the fix/gaussian_2d_kernel branch February 7, 2023 14:16
@mloskot mloskot modified the milestones: Boost 1.82, Boost 1.83+ Mar 31, 2023
@striezel striezel mentioned this pull request Jun 30, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat/bug But reports and bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants