I know how to find the edges from a picture. But I would like to have the outline edges be thicker for example width 9.
from PIL import Image, ImageFilter
image = Image.open('your_image.png')
image = image.filter(ImageFilter.FIND_EDGES, width=9)
image.save('new_name.png')
is that possible?
You can find edges and fatten them like this:
#!/usr/bin/env python3
from PIL import Image, ImageMorph, ImageFilter
# Open star image and ensure greyscale
im = Image.open('star.png').convert('L')
# Detect edges and save
edges = im.filter(ImageFilter.FIND_EDGES)
edges.save('DEBUG-edges.png')
# Make fatter edges and save
fatEdges = edges.filter(ImageFilter.MaxFilter)
fatEdges.save('DEBUG-fatEdges.png')
# Make very fat edges and save
veryFatEdges = edges.filter(ImageFilter.MaxFilter(7))
veryFatEdges.save('DEBUG-veryFatEdges.png')

Top-left=original, top-right=edges, bottom-left=fat edges, bottom-right=very fat edges.
You could use ImageMorph module for more controlled morphology, but the maximum filter is very effective as it is.
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