O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

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

Custom filters

So far we have seen filters that are used commonly in image processing and are widely accepted by researchers and developers. But there are times when you want to design your own filter. The good news is you do not have to write the entire convolution process again from scratch. Skimage and pillow both provide the option of applying custom filters on images.

The following function can be used to create a kernel for a filter in pillow:

>>> from PIL import ImageFilter>>> kernel = ImageFilter.Kernel((3,3), [1,2,3,4,5,6,7,8,9])

The kernel function takes the size, the sequence of kernel weights, the scale, and the offset as parameters, where size is the size of the matrix, scale is the value by which the result of the pixel is divided, ...

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