00:00 Image Processing Using Pillow in Python. Previously in the course, you’ve learned how to crop and rotate images, resize them, and extract color bands from color images. However, none of the actions that you’ve taken so far have made any changes to the content of the image. In these sections of the course, you’ll learn about image processing features in the Python Pillow library.
00:29 One of the methods that’s used in image processing is image convolution using kernels. A detailed explanation of image processing theory is outside the scope of this course, but if you’re interested in the science of image processing, one of the best resources you can use is Digital Image Processing by Gonzales and Woods, which is seen on-screen. In this section, you’ll learn the basics of how you can use convolution kernels to perform image processing. But what is a convolution kernel?
01:12 The line is four pixels wide, and the dot consists of a 4x4 pixel square. The image is seen on-screen, enlarged for display purposes. You can place the kernel anywhere on the image and use the location of the kernel’s central cell as a reference.
01:51 A new image can be created as a result of the convolution of the image with the kernel. Let’s take a look at kernel position 1. The position of the kernel is (3, 2), which is the position of its central cell because it’s in the fourth row with index of 3, and the third column with index of 2.
02:37 The multiplication of this pixel value, 255, multiplied by the kernel value of 1/9, gives 28.33. The eight remaining multiplications are still zero because all of those other image pixels are zero.
03:00 The third kernel position is at (8, 11). There are four non-zero image pixels overlapping with this kernel. Each one has a value of 255, so the multiplication result for each of them will be 28.33.
03:24 Remember that this is only the three kernel positions shown in the diagram. The convolution process repeats this process for every possible kernel position in the image, which gives a new value for each pixel position. In the image
The Pillow library has several built-in kernels and functions that will perform the convolution described here. You don’t need to understand the math of filtering through convolution to use these filters, but it always helps to know what’s happening behind the scenes when using these tools. The following sections of the course will look at the kernels and image filtering capabilities available in the
ImageFilter module in Pillow, starting by looking at blurring, sharpening, and smoothing.
Become a Member to join the conversation.