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

Add support for radius input parameter to Blur function #135

Open
bgreenblatt opened this issue Jan 7, 2021 · 2 comments
Open

Add support for radius input parameter to Blur function #135

bgreenblatt opened this issue Jan 7, 2021 · 2 comments

Comments

@bgreenblatt
Copy link

bgreenblatt commented Jan 7, 2021

I have a requirement to supply the radius instead of calculating it based on the sigma input. I implemented it like this:

-func Blur(img image.Image, sigma float64) *image.NRGBA {
+func Blur(img image.Image, sigma float64, radius int) *image.NRGBA {
        if sigma <= 0 {
                return Clone(img)
        }
 
-       radius := int(math.Ceil(sigma * 3.0))
+       if radius == 0 {
+               radius = int(math.Ceil(sigma * 3.0))
+       }

Let me know what you think.

@disintegration
Copy link
Owner

Indeed, it may be useful sometimes to control the radius parameter separately from the sigma, but this requires changing the signature of the function. This would break other people's code.

@bgreenblatt
Copy link
Author

Makes sense. Maybe better to add a new API that supports both parameters and has some code duplication

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

No branches or pull requests

2 participants