Time for action – trying to remove different types of noise

Let's go back to our holiday in Rome picture. We will add different types of noise to it and then filter the noisy result with our blurring kernels:

  1. Once again, we will start with loading our image:
    >> img = imread('holiday_image2.bmp'),
  2. Now let's add four kinds of noise to it (we'll use the default settings):
    >> gauss = imnoise(img,'gaussian'),
    >> poiss = imnoise(img,'poisson'),
    >> speck = imnoise(img,'speckle'),
    >> snp = imnoise(img,'salt & pepper'),
  3. First, we will write a small function that takes the original image, the distorted image, and the type of noise as input; performs filtering with our three filters and displays the results. We'll name our function DenoiseAndPlot.m:
    function DenoiseAndPlot(original,distorted,type)
    
    % Function that performs filtering of the distorted image with % three different kernels and displays the results
    % Inputs:
    %      original  - Original image
    %      distorted – Image distorted by noise
    %      type      – Type of noise
    %      (1: Gaussian, 2: Poisson, 3: speckle, 4: Salt & Pepper)
    
    switch type
      case 1
        message = 'Noisy image (Gaussian)';
      case 2
        message = 'Noisy image (Poisson)';
      case 3
        message = 'Noisy image (speckle)';
      case 4
        message = 'Noisy image (Salt & Pepper)';
    end
    f1 = BlurImage(distorted,1,2,1);
    f2 = BlurImage(distorted,2,[5,5],1);
    f3 = BlurImage(distorted,3,[5,5,2],1);
    subplot(2,3,1),imshow(original),title('Original image')
    subplot(2,3,2),imshow(distorted),title(message)
    subplot(2,3,4),imshow(f1),title('Filtered by disk kernel')
    subplot(2,3,5),imshow(f2),title('Filtered by averaging kernel')
    subplot(2,3,6),imshow(f3),title('Filtered by Gaussian kernel')
  4. Now, we will call our function for the case of Gaussian noise:
    >> DenoiseAndPlot(img,gauss,1);
  5. The result of the preceding code is as follows:
    Time for action – trying to remove different types of noise
  6. We can observe that all three filters have a comparable result, with the average filter causing more detail loss.
  7. Now, we'll try to remove the Poisson noise using our known filters:
    >> DenoiseAndPlot(img,poiss,2);
    Time for action – trying to remove different types of noise
  8. Once again, all three filters have a comparable result, with the average filter causing more detail loss.
  9. It's time for the third type of noise, which is speckle noise. Once more we execute:
    >> DenoiseAndPlot(img,poiss,3);
    Time for action – trying to remove different types of noise
  10. The results are again similar to previous cases of noise.
  11. Let's finally try the salt & pepper noise:
    >> DenoiseAndPlot(img,snp,4);
    Time for action – trying to remove different types of noise
  12. The result accomplished for the salt and pepper case appears quite noisy for all three filters. This gives us a hint that maybe these three blurring filters are not equally successful for all types of noise. The deduction is really intuitive, but still, we would have to find another filter that works better, at least for the salt and pepper noise.

What just happened?

First of all, we made a very wise choice by writing a function that performs the repeating parts of our code, which were quite lengthy. The only thing that changed according to our choice of filter was the title of the noisy image. Hence, we included a switch clause to change our message depending on the type of noise. All other lines in our function are pretty straightforward. We passed the noisy image through all of our filters using the BlurImage function we made earlier and displayed all the results in the same figure as the original and noisy images.

The results we got were decent for all cases, except the case of salt & pepper noise. Nothing exceptional and perfect, but the resulting images were generally an improvement over the noisy ones.

Hence, these three filters can be used for denoising purposes in cases of:

  • Image sensor noise in the brighter parts of an image, which normally resembles the Poisson noise. This kind of noise is usually called shot noise.
  • Image sensor noise in the darker parts of an image, which normally resembles the Gaussian noise. This kind of noise is usually called amplifier noise.
  • Film grain noise, which also can be modeled by Gaussian noise.
  • Noise that appears in SAR (Synthetic Aperture Radar) images, which is granular and appears like speckle noise.

However, the case of noise added by A/D (Analog to Digital) conversion or by errors in image data bits during transmission cannot be handled very effectively by these filters. This is why we will now visit another very important filtering method, called median filtering.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset