Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Edge Detection, Enhancement, and Embossing

00:00 Edge Detection, Edge Enhancement, and Embossing. When you look at an image, it’s relatively easy to determine the edges of the objects within it. It’s also possible for an algorithm to detect those edges automatically using edge detection kernels.

00:16 The ImageFilter module in Pillow has a predefined kernel to achieve this. In this section, you’ll use the image of the buildings again and convert it to grayscale before you apply the edge detection filter.

00:30 If you’re starting a new REPL session, then you’ll need to import Image and ImageFilter from Pillow and then import the image. But

00:48 if you’re carrying on from the previous session in the course, you can continue here.

01:03 The result is an image showing the edges from the original. This filter identifies the edges in the image. You can obtain a better outcome by applying the ImageFilter.SMOOTH filter before finding the edges.

01:37 On-screen, you can see a comparison of the original grayscale image and the two edge detection results. You can also enhance the edges of the original image with the ImageFilter.EDGE_ENHANCE filter.

02:02 You used a smoothed version of the grayscale image to enhance the edges. A portion of the original grayscale image and the image with the edges enhanced are shown side by side on-screen.

02:14 Another predefined filter in ImageFilter that deals with object edges is ImageFilter.EMBOSS. You can pass it as an argument to .filter() as you did with the other filters you’ve already seen.

02:28 You are using the smooth grayscale version as a starting point for the filter. You can see the embossed image on-screen, which shows a different effect using the edges in the image.

02:42 You’ve learned about several filters available in the ImageFilter module that you can apply to images. But other filters are available in ImageFilter and on-screen you can see a link to the ImageFilter documentation.

02:56 In the next part of the course, you’ll deepen your understanding of Pillow by looking at segmentation and superimposition of images.

Become a Member to join the conversation.