Convolution in the Two Dimensional Domain
The mathematical definition for 2D convolution is :
In practice, this is rewritten as :
where m2 is equal to half of the mask’s width and n2 is equal to half of the mask’s height, that is,
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.
Step 1 (Sample Matrix [filled with 0 on all sides])
Step 2 (Iteration 1)
Step 3 (Iteration 2 [shifting convolution to the right])
Step N (Iteration N [bottom right, final operation])
SO THE FINAL OUTPUT IS :
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.