Time for action – removing salt & pepper with medfilt2

We will start in the usual way and try to remove the salt & pepper noise from our image, using the median filtering function offered by MATLAB.

  1. Let's load our image and add salt & pepper noise to it:
    >> img = imread('holiday_image2.bmp'),
    >> snp = imnoise(img,'salt & pepper'),
  2. Now, let's filter it and show the results:
    >> denoised = medfilt2(snp,[5,5]);figure
    >> subplot(1,3,1),imshow(img),title('Original image')
    >> subplot(1,3,2),imshow(snp),title('Noisy image
      (Salt&Pepper)')
    >> subplot(1,3,3),imshow(denoised),title('Denoised image')
    Time for action – removing salt & pepper with medfilt2

What just happened?

This is much better. It seems that we have found our preferred filtering solution for the case of salt and pepper noise. The only thing we did was to apply median filtering to our image that was distorted by salt and pepper noise, using a 5x5 kernel.

Have a go hero – denoising real images

Now that you have learned most of the filters for noise removal, it is time to put them to the test with real noise. You should download problematic pictures, for example, taken with a high ISO setting, or bad JPEG compression artifacts and then try to find which filter can de-noise them more successfully. A simple search for noisy images on the internet should provide a multitude of examples to work on.

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

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