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 commentaires

agung pratama
agung pratama le 22 Juil 2020
What is M and V mean?
Image Analyst
Image Analyst le 13 Août 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.

Connectez-vous pour commenter.

 Réponse acceptée

Image Analyst
Image Analyst le 1 Nov 2014

1 vote

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 commentaires

Abirami
Abirami le 1 Nov 2014
thank u so much sir. May i know why we use ones(3)/9 and 'same'.
Image Analyst
Image Analyst le 1 Nov 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 le 1 Nov 2014
Modifié(e) : Abirami le 1 Nov 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 le 1 Nov 2014
thank u so much sir...
agung pratama
agung pratama le 5 Août 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 le 7 Août 2020
Modifié(e) : agung pratama le 7 Août 2020
Thanks, this is the image i attach here, because i still got error
Image Analyst
Image Analyst le 7 Août 2020
agung, you have to put in that code after you read in gray image. See attached.
agung pratama
agung pratama le 12 Août 2020
Thakhs Image Analyst,
Can you explaine to me [3 3] means in
medianFilteredImage = medfilt2(noisyImage, [3 3]);
Image Analyst
Image Analyst le 13 Août 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 le 13 Août 2020
Thanks Image Analyst, have a good day

Connectez-vous pour commenter.

Plus de réponses (1)

lakpa tamang
lakpa tamang le 15 Déc 2019

0 votes

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

3 commentaires

Image Analyst
Image Analyst le 15 Déc 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 le 28 Déc 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 le 28 Déc 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.

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by