I have been trying to blur an image using the PIL.
from what I know i need to copy the image, and then change every pixel to the average of the pixels surrounding him, from the original picture. so I didn't get really far, i'm using python 3.3x
from PIL import Image
img = Image.open("source")
im = Image.copy(img)
I know how to use putpixe, and get a pixel's data, but I can't figure out how to get the average of the pixels around.
Thanks in advance for the help!
You can just do:
blurred_image = original_image.filter(ImageFilter.BLUR)
See the ImageFilter module for more options.
You are correct in that the process you describe would blur the image, and there are filters that essentially directly do what you suggest (*e.g.", using the ImageFilter.Kernel
method where you kernel has constant weights). Using ImageFilter
will be faster and easier though, and give you more options for blurring and beyond.