It's never too late to share a solution. Try this ...
def change_img_edge(image, thickness, edge_color = (0,255,0, 200)):
# Iterate thickness-times.
# When image is filtered in next cycle, the detected edge moves outwards
for t in range(thickness):
msk = image.filter(ImageFilter.FIND_EDGES)
msk_data, img_data = msk.getdata(), image.getdata()
# Get image size
w, h = img_data.size
output = []
for y in range(0, h):
for x in range(0, w):
idx = x + w*y
curr_pxl = (0,0,0,0)
if msk_data[index][3]>0:
curr_pxl = edge_color
else:
curr_pxl = img_data[idx]
output.append(curr_pxl)
img.putdata(output)
return image
# Example usage
image = Image.open('your_image.png')
image = image.convert("RGBA")
image = change_img_edge(image, 5, (0,255,255, 200))
image.save('new_name.png')