I'm trying to blur an image with Pillow, using the ImageFilter as follows:
from PIL import ImageFilter
blurred_image = im.filter(ImageFilter.BLUR)
This works fine, except that it has a set radius which is way too small for me. I want to blur the image so much that it can be barely recognised anymore. In the docs I see that the radius is set to 2 by default, but I don't really understand how I can set it to a larger value?
Does anybody have any idea how I could increase the blur radius with Pillow? All tips are welcome!
PIL. ImageFilter. GaussianBlur(): This method creates a Gaussian blur filter. The filter uses radius as a parameter and by changing the value of this radius, the intensity of the blur over the image gets changed.
radius. The radius of the blur, specified as a <length> . It defines the value of the standard deviation to the Gaussian function, i.e., how many pixels on the screen blend into each other; thus, a larger value will create more blur. A value of 0 leaves the input unchanged.
Practical Data Science using Python Blurring an image can be done by reducing the level of noise in the image by applying a filter to an image. Image blurring is one of the important aspects of image processing. The ImageFilter class in the Pillow library provides several standard image filters.
Image.filter()
takes an ImageFilter
so you can create an ImageFilter.GaussianBlur
instance with whatever radius you want, passed in as a named argument.
blurred_image = im.filter(ImageFilter.GaussianBlur(radius=50))
You can even make it more concise like so:
blurred_image = im.filter(ImageFilter.GaussianBlur(50))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With