Simple and gaussian convolution techniques

Convolution does a similar work as the box averaging. In the convolution technique, we define the box and initialise it with the values. For denoising purposes, we initialise the box such that it behaves like averaging box. The convolution box is called the kernel. The kernel slides over the image. The value of the central pixel is replaced by the average of all the neighbour pixels spanned by the kernel. 

kernel working: The values of the kernel and respective pixel got multiplied and all such products got added to give the final result. If our kernel is of size [5 5] then we initialise the kernel with 1/25. When all the pixels got multiplied by 1/25 and added together, the final result is just the average of all those 25 pixels over which the kernel is placed at a certain point in time.

The advantage of convolution over box averaging is that sometimes the convolution filter (kernel) is separable and we break the larger kernel into two or more pieces. It reduces the computational operations to perform. 

Example:

Matlab

% MATLAB code for denoised imaged using
% convolution filter technique
% Read the cameraman image.
k1=imread("cameraman.jpg");
 
% create the noise.
n=25*randn(size(k1));
 
% add the noise to the image = noisy_image
k2=double(k1)+n;
 
% create the kernel of size [5 5]
h1=ones(5,5)*1/25;
 
% convulse the image with the kernel.
k3=uint8(conv2(k2, h1,'same'));
 
% display the denoised image.
imtool(k3,[]);
 
% create the kernel of size [9 9]
h2=ones(9,9)*1/81;
 
% convulse the image with the kernel.
k4=conv2(k2,h2,'same');
 
% display the denoised image.
imtool(k4,[]);

                    

Output:

A drawback of this technique is:

  • It also introduces the blurriness in the image in addition to reducing the noise.
  • The image gets blurred at the edges due to the wrong averaging result.

Gaussian Filter: 

This kernel or filter has more weightage for the central pixel. While averaging at the edges, more weightage is given to the edged pixel and thus it gives us the pixel value close to the actual one, therefore, reduces the blurriness at the edges. 

Keep in mind that if we increase the size of the filter, the degree of denoising increases and also the blurriness. But blurriness is significantly less in comparison to other averaging techniques.

Example:

Matlab

% MATLAB code for denoised using
% Gaussian Filter:
k1=imread("cameraman.jpg");
 
% create the noise.
n=25*randn(size(k1));
 
% add the noise to the image = noisy_image
k2=double(k1)+n;
 
%create and print the kernel of size [3 3]
h1=fspecial('gaussian',3,1);
h1
 
% convulse the image with the kernel.
k3=uint8(conv2(k2, h1,'same'));
 
% display the denoised image.
imtool(k3,[]);
 
% create and print the kernel of size [20 20]
h2=fspecial('gaussian',20,1);
h2
 
% convulse the image with the kernel.
k4=uint8(conv2(k2,h2,'same'));
 
% display the denoised image.
imtool(k4,[]);

                    

Output:

Denoising techniques in digital image processing using MATLAB

Denoising is the process of removing or reducing the noise or artifacts from the image. Denoising makes the image more clear and enables us to see finer details in the image clearly. It does not change the brightness or contrast of the image directly, but due to the removal of artifacts, the final image may look brighter.

In this denoising process, we choose a 2-D box and slide it over the image. The intensity of each and every pixel of the original image is recalculated using the box. 

Similar Reads

Box averaging technique:

Box averaging can be defined as the intensity of the corresponding pixel would be replaced with the average of all intensities of its neighbour pixels spanned by the box. This is a point operator....

Simple and gaussian convolution techniques:

...

Denoising by averaging noisy images:

Convolution does a similar work as the box averaging. In the convolution technique, we define the box and initialise it with the values. For denoising purposes, we initialise the box such that it behaves like averaging box. The convolution box is called the kernel. The kernel slides over the image. The value of the central pixel is replaced by the average of all the neighbour pixels spanned by the kernel....