Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Failed to add uniform noise to the image

Asked by Sajid Khan on 14 May 2013

Hi Everyone, I am trying to add uniform noise using the following syntax,

image = ones([512,512])*128;

A = .1;

B = .2;

matrix_uniform = A + (B-A)*rand(size(image));

noisy_image = imnoise(uint8(image),'localvar',matrix_uniform);

K = wiener2(noisy_image,[5 5]);

figure, subplot(1,3,1),imshow(noisy_image), subplot(1,3,2), imshow(K),

subplot(1,3,1), imhist(noisy_image)

But I am unable to get uniform shape in the histogram. Can anyone tell me what wrong I am doing?

0 Comments

Sajid Khan

Products

No products are associated with this question.

1 Answer

Answer by Iman Ansari on 14 May 2013
Accepted answer

Hi. You don't need imnoise:

round(128+0.2)=128

with 0.1 and 0.2 like you didn't add any noise. Uniform noise with zero mean:

image = ones([512,512])*128;
A = -30;
B = 30;
matrix_uniform = A + (B-A)*rand(size(image));
noisy_image = image + matrix_uniform;
figure,
subplot(1,2,1)
imshow(noisy_image./255), 
subplot(1,2,2)
imhist(uint8(noisy_image))

0 Comments

Iman Ansari

Contact us