2948 explained code solutions for 75 technologies


python-pillowHow to find image edges


from PIL import Image, ImageFilter

im = Image.open('/var/www/examples/heroine.png')
im = im.convert("L")
im = im.filter(ImageFilter.FIND_EDGES)

im.show()ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

.convert("L")

convert image to grayscale to prepare it for edge detection

.filter(

apply given filter to an image

ImageFilter.FIND_EDGES

this filter highlights edges of an image and removed everything else

.show()

displays resulting image


How to find image edges, python pillow

Usage example

from PIL import Image, ImageFilter

im = Image.open('/var/www/examples/heroine.png')
im = im.convert("L")
im = im.filter(ImageFilter.FIND_EDGES)

im.show()