Gaussian Filter

Syntax: 

 B = imgaussfilt(A, sigma); // To obtain the filtered image using gaussian filter:

// imgaussfilt() is the built-in function in Matlab, which takes 2 parameters.

To display the noisy and denoised image side by side in single frame: imshowpair(P{noisy, denoised}); title(noisy vs denoised’);

Example:

Matlab




% MATLAB code using Gaussian Filter
% read the image.
k=imread("einstein_colored.jpg");
  
% convert to grayscale.
k=rgb2gray(k);
  
% create the image corrupted with gaussian noise
gaussian_noise=imnoise(k,'gaussian',0,0.01);
  
% create the image corrupted with poisson noise
poisson_noise=imnoise(k,'poisson');
  
% create the image corrupted with salt & pepper noise
salt_noise=imnoise(k,'salt & pepper', 0.05);
  
% create the image corrupted with speckle noise
speckle_noise=imnoise(k,'speckle', 0.05);
  
% get the denoised image from gaussian_noise image.
gaussian_denoised=imgaussfilt(gaussian_noise,1);
  
% get the denoised image from poisson_noise image.
poisson_denoised=imgaussfilt(poisson_noise, 1);
  
% get the denoised image from salt_noise image.
salt_denoised=imgaussfilt(salt_noise, 1);
  
% get the denoised image from speckle_noise image.
speckle_denoised=imgaussfilt(speckle_noise, 1);
  
% display noised and denoised images side by side.
montage({gaussian_noise,gaussian_denoised }); 
title('Gaussian noise and denoised image using gaussian filter');
  
% display noised and denoised images side by side.
montage({poisson_noise,poisson_denoised}); 
title('poisson noise img vs poisson denoised img');
  
% display noised and denoised images side by side.
montage({salt_noise,salt_denoised}); 
title('salt&pepper noise img vs denoised img');
  
% display noised and denoised images side by side.
montage({speckle_noise,speckle_denoised}); 
title('speckle noise img vs speckle denoised img');


Output:

Figure: Gaussian noise

 

Figure: Poisson noise

 

Figure: Salt and pepper noise

 

Figure: Speckle noise

Gaussian filter relatively works better with gaussian and poison noise. 

What are different types of denoising filters in MATLAB?

Digital images are prone to various types of noise that make the quality of the images worst. Image noise is a random variation of brightness or color information in the captured image. Noise is basically the degradation in image signal caused by external sources such as cameras. Images containing multiplicative noise have the characteristic that the brighter the area the noisier it. We shall discuss various denoising filters in order to remove these noises from the digital images. 

Types of filters discussed in this article are listed as:

  • Mean filter
  • Median filter
  • Gaussian filter  
  • Wiener filter

Similar Reads

Mean Filter

It is also called as Box Averaging filtering technique.  It uses a kernel and is based on convolution. It calculates the average of all a pixel and its surrounding pixels and the result is assigned to the central pixel. It is a very effective technique for the removal of Poisson noise....

Median Filter

...

Gaussian Filter

A Median filter is a non-linear filter. It sorts the pixels covered by the window and sorts them in ascending order then returns the median of them....

Wiener Filter

...