Get startedGet started for free

Jump into filtering

1. Jump into filtering

Awesome work on completing Chapter 1! In this new chapter we'll learn about filtering, contrast, transformations and morphology! Let's start with something we are using almost daily, filters.

2. Filters

Filtering is a technique for modifying or enhancing an image. In essence, a filter is a mathematical function that is applied to images. It can be used to emphasize or remove certain features, like edges. Smoothing, sharpening and edge detection. In this video we will cover smoothing and edge detection. Filtering is a neighborhood operation, lets see what that means.

3. Neighborhoods

Certain image processing operations involve processing an image in sections, called blocks or neighborhoods, rather than processing the entire image at once. This is the case for filtering, histogram equalization for contrast enhancement, and morphological functions, all three of which use this approach.

4. Edge detection

So, with filtering we can detect edges. This technique can be used to find the boundaries of objects within images. As well as segment and extract information like how many coins are in an image. Most of the shape information of an image is enclosed in edges.

5. Edge detection

Edge detection works by detecting discontinuities in brightness. Like in this image, where we spot the chocolate kisses shapes in the image.

6. Edge detection

A common edge detection algorithm is Sobel. This is a filter that we can find in scikit image's module filters with the sobel function. The previously used coins image is preloaded as image coins. We apply the filter by passing the image we want to detect the edges from as parameter. This function requires a 2-dimensional grayscale image as input. So in the case of a colored image, we'll need to convert it to grayscale first. Then, we show the original and the resulting image with a function that uses Matplotlib subplots.

7. Edge detection

So we see that the filter is detecting the edges in the original image and highlighting the boundaries as closed lines in the resulting image.

8. Comparing plots

This is the plot comparison function we just used. It plots the original image next to the resulting one. Using this function allows us to reuse this code and focus more on the image processing part of the code.

9. Gaussian smoothing

Lets look at another filtering technique, smoothing. We can achieve this with a Gaussian filter. This technique is typically used to blur an image or to reduce noise. Here we see the effect of applying a Gaussian filter, which can especially be seen in the edges of the dogs hair. The Gaussian filter will blur edges and reduce contrast. This is used in other techniques like anti-aliasing filtering.

10. Gaussian smoothing

Lets see how we can do this with Scikit image using this picture of me in Amsterdam.

11. Gaussian smoothing

We import the Gaussian function from the filters module of scikit-image. To apply the filter, the original image is passed as first parameter to the Gaussian function and the multichannel boolean parameter is set to True if the image is colored, otherwise it needs to be set to False. Finally, lets compare the original and the resulting image.

12. Gaussian smoothing

Sometimes when the image is too large, meaning it has a big resolution, we do not easily see the effect. Lets look more closely at the image.

13. Gaussian smoothing

Here, we can see more clearly how the Guassian filter is blurring the image and removing the noise.

14. Let's practice!

Now it is your turn to apply filtering! Lets get started.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.