Hello, I'm working on image encryption. I need to see how well my encryption is so i thght of adding noise and testing it.I added gaussian noise with the following code.My problem is i dont know how to remove it before applying decryption algorithm.i get decimal values, I want to get whole numbers in the resulting matrix.
I=imread('leena.bmp');
M =0;
V=0.01;
imshow(I);
title('Original Image');
J = imnoise(I,'gaussian',M,V);
gure,imshow(J);
title('Gaussian Noise');
i'm planning to add other noises as well like poisson noise, speckle noise and salt and pepper noise. Is there any possibility that a code exists for removing all these noises separately? please help..thanks in advance

2 comentarios

agung pratama
agung pratama el 22 de Jul. de 2020
What is M and V mean?
Image Analyst
Image Analyst el 13 de Ag. de 2020
Did you look up imnoise() in the help? M is the mean and V is the variance. From the help:
J = imnoise(I,'gaussian',m,var_gauss) adds Gaussian white noise with mean m and variance var_gauss.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 1 de Nov. de 2014

1 voto

For Gaussian noise, the maximum likelihood de-noised answer would just be a local mean, which you can do with conv2():
denoisedImage = conv2(double(noisyImage), ones(3)/9, 'same');
If you want to do Salt and Pepper noise, then see my attached demos where I use a modified median filter.

12 comentarios

Abirami
Abirami el 1 de Nov. de 2014
thank u so much sir. May i know why we use ones(3)/9 and 'same'.
Image Analyst
Image Analyst el 1 de Nov. de 2014
ones gives a 3 by 3 local window where it multiplies each element of that by the value of the image when it's over that part of the image. Then it slides along to the next location until it's scanned the whole image. 'same' makes the output image be the same size as the input image, otherwise it's larger because it's possible for just one row or column of the window to overlap the image when it's positioned at the last row or column. This is the "edge effect" or "boundary effect".
Abirami
Abirami el 1 de Nov. de 2014
Editada: Abirami el 1 de Nov. de 2014
sir but the resulting image has decimal values. how do i convert them to whole numbers so that i carry out the decryption.the image im using is a 256x256 greyscale image. please help...thanks in advance.
denoisedImage = uint8(denoisedImage);
Abirami
Abirami el 1 de Nov. de 2014
thank u so much sir...
agung pratama
agung pratama el 5 de Ag. de 2020
i got error while using
for my gray image
Error using medfilt2
Expected input number 1, A, to be two-dimensional.
Error in medfilt2>parse_inputs (line 107)
validateattributes(a, ...
Error in medfilt2 (line 49)
[a, mn, padopt] = parse_inputs(args{:});
Error in salt_and_pepper_noise_removal_grayscale (line 40)
medianFilteredImage = medfilt2(noisyImage, [3 3], 'syimmetric');
Looks like your gray image is actually an RGB image. It may look gray but it has 3 color channels, so probably all three channels are identical. Try this:
if ndims(grayImage) > 1
grayImage = grayImage(:, :, 1);
end
If that still doesn't work, attach your script and image so I can fix it.
agung pratama
agung pratama el 7 de Ag. de 2020
Editada: agung pratama el 7 de Ag. de 2020
Thanks, this is the image i attach here, because i still got error
Image Analyst
Image Analyst el 7 de Ag. de 2020
agung, you have to put in that code after you read in gray image. See attached.
agung pratama
agung pratama el 12 de Ag. de 2020
Thakhs Image Analyst,
Can you explaine to me [3 3] means in
medianFilteredImage = medfilt2(noisyImage, [3 3]);
Image Analyst
Image Analyst el 13 de Ag. de 2020
If you check the documentation you'll see that it's the window size of the window that scans across the image.
agung pratama
agung pratama el 13 de Ag. de 2020
Thanks Image Analyst, have a good day

Iniciar sesión para comentar.

Más respuestas (1)

lakpa tamang
lakpa tamang el 15 de Dic. de 2019

0 votos

Image Analyst.. can you explain how does the denoising works actually.. mathamatically?

3 comentarios

Image Analyst
Image Analyst el 15 de Dic. de 2019
It depends on the algorithm but essentially it tries to determine what is noise and what is signal at that point, and replace the actual value with the signal-only value. Different algorithms make different assumptions on what is noise and what is signal.
RAJSHREE SRIVASTAVA
RAJSHREE SRIVASTAVA el 28 de Dic. de 2020
Image analyst , I am trying to excute the last file of
But I am getting error : salt_and_pepper_noise_removal_grayscale
Undefined function or variable 'salt_and_pepper_noise_removal_grayscale'.
Please do help
Image Analyst
Image Analyst el 28 de Dic. de 2020
How are you trying to run it? Is it open in the editor window? Did you click the green run triangle? Then it will run. I just ran it again to make sure everything works fine, and it does.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 1 de Nov. de 2014

Comentada:

el 28 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by