Friday, October 11, 2013

Image Filtering Basics: Convolution and Correlation.

Let's consider two images I and F. I is input image and F is mask.

Correlation

For convolution we keep center of mask matrix over every pixel of input image update that value with weighted sum of every other pixel covered by the mask.

As can be seen from the above image, in the 10 is the center of  area covered by mask in 'I'.
So in output image that value is updated by the the expression given in the image. This operation is repeated for every pixel of the input image and output image is constructed. 

As you might have guessed by now that given mask computes average values in the neighborhood and updates the center pixel with this new value. As a result we get a smoother image in output. Saying that output will be a smoother image is quite intuitive, clearly every pixel in the output image (o) will have a component from the neighboring pixels. This components decrease the difference in intensities values of neighboring pixels. Hence change in intensity while moving across new image is lesser or in other words smoother.   

If we change the mask we get different results. For example if change the value of the center pixel of the mask by 2. The the image obtained by taking convolution will have more weight to the current pixel being scanned. 

Lets see few example of this operation:

1) Here F has only center pixel as 1. Therefore contribution from neighbors is 0 and there is no change in image. 

2) Shift operator
 3) Blur operator which we discussed in the main part
In the next post we are going to discuss how to perform convolution with opencv.

No comments:

Post a Comment