Convolution in the Two Dimensional Domain

The mathematical definition for 2D convolution is :
2D convolution
In practice, this is rewritten as :
2D convolution
where m2 is equal to half of the mask’s width and n2 is equal to half of the mask’s height, that is,
2D convolution
and
2D convolution
where [x] is the floor operator, which rounds a number to the nearest integer less than or equal to x. The basic mechanism used to understand 1D convolution can be expanded to the 2D domain. In such cases, the 2D array A is usually the input image and B is a small (usually 3×3) mask. The idea of mirroring B and shifting it across A can be adapted to the 2D case as well: mirroring will now take place in both x and y dimensions, and shifting will be done starting from the top left point in the image, moving along each line, until the bottom right pixel in A has been processed.

Example

Step 1 (Sample Matrix [filled with 0 on all sides])


2D convolution Sample matrix and convolution
Step 2 (Iteration 1)


2D convolution Iteration 1
Step 3 (Iteration 2 [shifting convolution to the right])


2D convolution Iteration 2
Step N (Iteration N [bottom right, final operation])


2D convolution Iteration N

SO THE FINAL OUTPUT IS :
2D convolution Final Outputjpg

Convolution with masks is a very versatile image processing method. Depending on the choice of mask coefficients, entirely different results can be obtained, for example, image blurring, image sharpening, or edge detection.

Share

You may also like...

1 Response

  1. Elisa says:

    Excellent article! We are linking to this great article on our site.
    Keep up the great writing.