Javatpoint Logo
Javatpoint Logo

Concept of Convolution

Convolution is used for many things like calculating derivatives, detect edges, apply blurs etc. and all this is done using a "convolution kernel". A convolution kernel is a very small matrix and in this matrix, each cell has a number and also an anchor point.

The anchor point is used to know the position of the kernel with respect to the image. It starts at the top left corner of the image and moves on each pixel sequentially. Kernel overlaps few pixels at each position on the image. Each pixel which is overlapped is multiplied and then added. And the sum is set as the value of the current position.

Concept of Convolution

Convolution is the process in which each element of the image is added to its local neighbors, and then it is weighted by the kernel. It is related to a form of mathematical convolution.

In Convolution, the matrix does not perform traditional matrix multiplication but it is denoted by *.

Suppose, there are two 3x3 matrices, one is kernel and another one is an image piece. In convolution, rows and columns of the kernel are flipped and then they are multiplied and then summing is performed. Elements which are present in the centre of matrix i.e. in [2,2] of the image will be weighted combination of the image matrix and the weights will be given by the kernel. Similarly, all the other elements of the matrix will be weighted and then weights will be computed.

Following is pseudo code to describe the convolution process:

Convolution can be computed using multiple for loops. But using for loops causes a lot of repeated calculation and also the size of image and kernel increases. Using Discrete Fourier Transform technique calculating convolution can be done rapidly. In this technique, the entire convolution operation is converted into a simple multiplication.

In convolution, the problem occurs when the kernel is near the edge or corners because the kernel is two dimensional.

To overcome these problems following things can be done:

  1. Ones can be ignored
  2. Extra pixels can be created near the edges.

Extra pixels can be created in the following ways:

  1. Duplicate edge pixel.
  2. Reflect edges
  3. Pixels can be copied from the other end.

Next TopicConcept of Mask





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA