Image Filtering#

Image filtering is working on the 2D image (after capturing). Filtering is very close to Convolution.

Image filtering is used to:

  • Enhance images

    • Denoise, resize, increase contrast etc.

  • Extract information from images

    • Textures, edges, distinctive points

  • Detect patterns

    • Template matching

When we apply a filter of size \(c \times c\) on an image of \(n \times n\) dimensiions, the resultant image (without image padding) is \((n-c+1) \times (n-c+1)\)

Convolution is a summation of element-wise multiplication of pixel intensities in an image region with the image filter that is applied.

In math terms,

\[ h[m,n] = \sum_{k,l}g[k,l] f[m+k, n+l] \]

Image filtering

Image filtering

**Image filtering with the above kernel achieves the smoothining effect. (removes sharp features).

Convolution#

../_images/convolution.PNG

Fig. 51 Convolution#

Why to flip the kernel?

To preserve commutative and associative properties of the convolution operation.

The convolution step measures how close the vectors are in terms of the angle between the vectors.

Convolution is very close to correlation, but we first flip the kernel vertically and horizontally and then compute the dot product to get each pixel of the output image.

See also

Visual representation of \(3 \times 3\) convolution filters is shown here and this git repo

Visual examples for image filtering are shown here

Information about strided convolution and non-strided convolution here given here

Image shift using convolution#

../_images/shift-convolution.PNG

Fig. 52 Shift using convolution#

Image Sharpening

Image Sharpening

Edge detection#

Sobel filter

Sobel filter