I have an image which consists of two arbitrarily placed black 1px "blobs" on a white canvas 100px by 200px. I'm trying to "blur these blobs by turning some of the neighbouring pixels (within a radius of 10px of each blob) black also. I've put together the following code, but am not quite sure of the next step..
import numpy as np
from PIL import Image
from scipy import ndimage
from matplotlib import pyplot
from matplotlib import cm
from scipy.misc import imsave
im = Image.open("test.png")
pix = np.asarray(im)
new_pix = np.copy(pix[:,:,0]) # need this otherwise can't write to the pix array.
pix_to_enlarge = np.where(new_pix != 255)
pixels_to_enlarge_by = 10
i=0
for each_pixel in pix_to_enlarge[0]: # this cycles through each non-white pixel
for y in range(len(new_pix)): # this looks across the length (down) the page
for x in new_pix[y]: # this looks across the x-axis for each y step
radius = pixels_to_enlarge_by**2
so essentially I've found the locations of the non-white pixels in the variable pixels_to_enlarge_by. What I'm trying (and so far failing to do) is to select the surrounding pixels (within 10px) and change them to black also. Any ideas?