Home > database >  Adding salt and pepper noise using MATLAB
Adding salt and pepper noise using MATLAB

Time:09-28

In an assignment, I have to add salt and pepper noise of specific SNR values to an image. How to achieve this using MATLAB ?

I know how to add salt and pepper noise with given noise density to an image (using imnoise)

CodePudding user response:

"SNR" is not a well-defined term, there are many, many ways in which you can define SNR for a specific application.

So if we define SNR as the number of signal pixels divided by the number of noise pixels (which is not a weird definition in the case of salt and pepper noise, where there is no noise on some pixels, and no signal on other pixels), then it is quite straightforward to translate that SNR to noise density.

On the other hand, if you have a specific definition of SNR that you need to abide by, then you could use an iterative process as follows:

  1. Pick a random pixel, and set it randomly to 0 or 1 (or whatever the max value is for your data type).
  2. Compute the SNR according to your definition.
  3. Go back to 1 if the computed SNR is larger than the required one.

This is obviously an expensive procedure...

  • Related