How to add 5% Gaussian noise to an image

we define that:

The "percentage noise" number represents the percentage of the standard deviation of white Gaussian noise from the signal for the entire image.

Suppose I have a brain image, I want to add 5% Gaussian noise to the whole image (tissues) by Matlab code:

I=imread('brain91.png'); I=rgb2gray(I);I=double(I);
I = I - min(I(:));
I = I / max(I(:));

%// Add noise to image
v = 0.05*var(I(:));
I_noisy = imnoise(I, 'gaussian', 0, v);
I_noisy=255.*I_noisy;
subplot(121);imshow(I,[]);subplot(122);imshow(I_noisy,[])

      

The figure shows the original image (left) and the noise image on the right. Do you think my implementation is correct for the definition above? - (about 5% Gaussian noise over the set v = 0.05 * var (I (:)))

enter image description here

+3


source to share


1 answer


Both Ander Biguri and Dasdinonein have correct statements. Your code will certainly add Gaussian noise to the image properly, but make sure you factor in the actual variance when you square 0.05

your calculation var

.

Alternatively, you can use std

instead of var

and align the whole calculation to get the same thing:



I=imread('brain91.png'); I=rgb2gray(I);I=double(I);
I = I - min(I(:));
I = I / max(I(:));

%// Add noise to image
%v = (0.05^2)*var(I(:)); %// Option #1
v = (0.05*std(I(:)))^2; %// Option #2
I_noisy = imnoise(I, 'gaussian', 0, v);
I_noisy=255.*I_noisy;
subplot(121);imshow(I,[]);subplot(122);imshow(I_noisy,[])

      

+3


source







All Articles