From the help:
J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.
Let's get the mean of the entire image
So, on average, I think you're saying you want sqrt(variance) to equal 40% of meanOfI. So now you know what v has to be. Try experimenting around a bit and see what you learn.
Perhaps this demo will be instructive:
clc;
close all;
imtool close all;
clear;
workspace;
format longg;
format compact;
fontSize = 14;
grayImage = imread('eight.tif');
subplot(2, 2, 1);
imshow(grayImage);
title('Original Gray Scale Image', 'FontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
noisyImage = imnoise(grayImage,'gaussian', 0, 0.02);
subplot(2, 2, 2);
imshow(noisyImage, []);
title('Noisy Image', 'FontSize', fontSize);
noiseOnly = single(noisyImage) - single(grayImage);
subplot(2, 2, 3);
imshow(noiseOnly, []);
title('Image of Only the Noise', 'FontSize', fontSize);
snrImage = abs(noiseOnly) ./ double(grayImage);
subplot(2, 2, 4);
imshow(snrImage, []);
title('Image of the Signal-to-Noise Ratio', 'FontSize', fontSize);
snrMean = mean2(snrImage);
message = sprintf('The mean Signal-to-Noise Ratio = %.2f', snrMean);
uiwait(msgbox(message));
Best Answer