imaging
imaging copied to clipboard
Add support for radius input parameter to Blur function
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.
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.
Makes sense. Maybe better to add a new API that supports both parameters and has some code duplication