Difference Between Correlation and Convolution
Difference Between Correlation and Convolution
Convolution
By /
November 2023
Correlation
is a mathematical technique to see how close two things are related. In image processing terms, it is used
to compute the response of a mask on an image. A mask is applied on a matrix from left to right. Mask
slides over the matrix from left to right by one unit every time. Once the mask reaches the rightmost end,
the mask is slid downward by one unit and again starts from left to right side. The computed output is
assigned to the central pixel, while neighbourhood pixels are also get used in the computation. The mask
or the matrix can be 1-D or 2-D. Generally, the mask’s dimension is taken as an odd number, so that the
central pixel can easily be found.
J(2) = I(1) . H(-1) + I(2) . H(0) + I(3) . H(1)Indexes are represented in the parentheses.
J(2) = 120 x 1/3 + 100 x 1/3 + 150 x 1/3 J(2) = 370/3 In general,
The size of the resultant image depends on padding. If padding is allowed, size of resultant image = size
of the original image (input) If padding is not allowed, size of resultant image < size of the input image. A
convolution is also a mathematical tool that is used to combine two things in order to produce the result.
In image processing, convolution is a process by which we transform an input image by applying a kernel
over it in a pixel-wise fashion. When the convolution mask operates on a particular pixel, then it performs
the action by considering that pixel and its neighbouring pixels and the result is returned to that one
particular pixel. Thus, we conclude that convolution in image processing is the mask operato
To find the output result, we start to follow our steps. We put the kernel on the image and after
multiplying each weight in the kernel by the corresponding pixels, we sum the products. Slide the kernel
and repeat the same steps.
Some Linear Filters: Averaging Filter (Blur Filter): There are several methods to blur an image and one of
them is averaging filter. To apply this filter we use correlation.
Convolution
Convolution is a mathematical operation used to combine two functions or signals to produce a third
function or signal. It is a widely used operation in the field of signal processing, signal filtering, image
analysis, computer vision. It is also used to extract information from an image. Convolution of two
signals or functions can be performed by using MATLAB. MATLAB provides a built-in function 'conv'
to perform convolution. The 'conv' function accepts two input vectors as arguments and gives their linear
convolution as the result.
We are using same mask not the flipped one, hence we shall use the indexes properly. Apply convolution
between image and mask at index=1 in the image.
J(2) = I(0) . H(1) + I(1) . H(0) + I(2) .
Convolution and correlation give the same response if the mask is symmetric. Both correlation and
convolution look similar in nature. But we use convolution extensively in image processing because of its
following properties.
But the code part is a bit different than the correlation filtering. Because there is nothing in opencv to
make the convolution filtering directly. To make convolution filtering, there are 2 different way: Flip the
kernel in both dimensions in the code and then call filter2D function . Use scipy library instead of opencv
to make convolution filtering.