
We shift the kernel by 3 pixels to the right/down to shrink the image.
#Gaussian window functiin in inmr Patch#
So for shrinking the original image, we can summarize it in the following steps:ġ) Put the kernel in the first patch of the original image and calculate the average and put it in the first pixel of new image 2) Move the kernel to the next patch, 3 pixels further (top-left cell of the kernel should be in forth pixel), and calculate the average. The averaging operation is a weighted sum (adding up all of the pixel values and divide it by the number of pixels which here is 9).

The second choice produces a better result. 2) take the average of 9-pixel values and put it in the new image. So each 3×3 pixels (9 pixels) in 12×12 image should be reduced to 1 pixel, to do that we can consider to ways:ġ) take the value of the pixel in the center of the 3×3 box and produce the 4×4 image (If there is no center cell in the kernel what we can do is using interpolation to estimate the value for the center cell), using this method results in some artifacts in the new image. To make things more clear about convolution and cross-correlation, let’s consider an example, say we have a 12×12 image and we want to shrink it to 4×4, as shown in Fig. That means, applying Fourier Transformation to the convolution of two functions in Spatial domain is equal to the product of Fourier Transformation of two functions:īy applying cross-correlation in Spatial domain is equal to the product of a function with complex conjugate of the other one:Ĭhoosing the size and values for the kernel depends on what we want to do with our image and we may talk about it in further articles. 1: Edge Detection Kernelīut which one should be used? We prefer to use convolution because it gives us a nice property which is the associativity. 1, represents an edge detection kernel and if we flip it to the x-axis (second row which includes the anchor point), the result would be the same kernel and also the result of convolution and correlation would be the same. So, don’t be surprised if people sometimes calculate the correlation and call it convolution. In Digital Image Processing, sometimes, results of convolution and correlation are the same, hence the kernel is symmetric (like Gaussian, Laplacian, Box Blur, etc.) and so flipping the kernel does not change the result by applying convolution.

The value that we use for each cell in a kernel determines its functionality. A kernel is just a matrix and we will use them to do some cool things such as sharpening, blurring, edge detection, etc. The only difference between Convolution and Cross-Correlation (Correlation) is that in Cross-Correlation there is no mirroring in function g.īut before continue we need to define kernel. Let’s have a look at difinition of Discrete Convolution and cross-correlation in mathematics:Īs we can see in convolution the function g, first, should be mirrored and then shifted step by step and finally, in each step, it will be multiplied by the function f and the results will be summed up. After reading this post you will learn Convolution as well as literally most of the computer vision because it appears somehow in all functions that we will use in the CV. In this post, we will continue to learn more about low-level computer vision which we’ve started in last post.
