Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 825 Bytes

how-to-find-image-edges.md

File metadata and controls

30 lines (22 loc) · 825 Bytes

How 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()
  • PIL - import lib: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

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()