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

Unlock This Lesson

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

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

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.