O'Reilly logo

Python Multimedia Beginner's Guide by Ninad Sathaye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - detecting and enhancing edges

Let's see how the edge detection and enhancement filters modify the data of a picture. The photograph that we will use is a close-up of a leaf. The original photo is shown in the next illustration. Applying an edge detection filter on this image creates a cool effect where only edges are highlighted and the remaining portion of the image is rendered as black.

  1. Download the image 0165_3_6_Before_EDGE_ENHANCE.png from the Packt website and save it as Before_EDGE_ENHANCE.png.
  2. Add the following code in a Python file.
    1 import Image 2 import ImageFilter 3 import os 4 paths = [ "C:\images\Before_EDGE_ENHANCE.png ", 5 "C:\images\After_EDGE_ENHANCE.png ", 6 "C:\images\EDGE_DETECTION_1.png ", 7 "C:\images\EDGE_DETECTION_2.png ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required