6: Spatial Filters

Spatial filters assign the value of a pixel based on their neighbors. Filters are defined as matrices, known as kernels, and are applied to an image through an operation known as a convolution.

The image being used for this post is a rgb2gray converted lena image. Each kernel is a 3x3 pixel image with numbers that determines how the image will be affected. In the example of horizontal and vertical sobel filters, the horizontal and vertical points are being focused on. In the example of the Gaussian blur, pixels in the center are focused on and corner pixels are blurred. This creates a bokeh effect.

Applying different Kernels

Increasing the size of these kernels causes the kernel to look at the larger size of pixels to operate on. Depending on the situation, this may improve or worsen the image.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nisarg Nigam

Nisarg Nigam

MS Data Science student at Asian Institute of Management