is it possible to write a code that experiments with zero mean Gaussian noise for a variance in the range 0.001 to 0.1

1 view (last 30 days)
is it possible to write a code or algorithm that basically does the following
J = imnoise(MEANPIC,'gaussian',0.001); h=figure; imshow(J); set(h,'Name','0.001');
J = imnoise(MEANPIC,'gaussian',0.002); h=figure; imshow(J); set(h,'Name','0.002');
J = imnoise(MEANPIC,'gaussian',0.003); h=figure; imshow(J); set(h,'Name','0.003');
J = imnoise(MEANPIC,'gaussian',0.004); h=figure; imshow(J); set(h,'Name','0.004');
J = imnoise(MEANPIC,'gaussian',0.005); h=figure; imshow(J); set(h,'Name','0.005');
J = imnoise(MEANPIC,'gaussian',0.006); h=figure; imshow(J); set(h,'Name','0.006');
J = imnoise(MEANPIC,'gaussian',0.007); h=figure; imshow(J); set(h,'Name','0.007');
J = imnoise(MEANPIC,'gaussian',0.008); h=figure; imshow(J); set(h,'Name','0.008');
J = imnoise(MEANPIC,'gaussian',0.09); h=figure; imshow(J); set(h,'Name','0.009');
J = imnoise(MEANPIC,'gaussian',0.01); h=figure; imshow(J); set(h,'Name','0.01');
is it possible to have some kind of range instead of having to write out the same code each time for the different variances. thanks

Accepted Answer

Rik
Rik on 4 Nov 2018
Yes, this is what for loops exist for.
variance_list=.001:.001:0.01;
for k=1:numel(variance_list)
J = imnoise(MEANPIC,'gaussian',variance_list(k));
h=figure; imshow(J);
set(h,'Name',sprintf('%.3f',variance_list(k)));
end

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!