PSNR CALCULATING MEDIAN FILTER GAUSSIAN FİLTER

3 vues (au cours des 30 derniers jours)
Ali Zulfikaroglu
Ali Zulfikaroglu le 23 Jan 2021
I am adding salt and pepper noise to original image.
and then I am filtering this noise with median filter and gaussian filter.
I want to get psnr values of median filter and gaussian filter effect on this salt and pepper noise and then compare this two filter which one have high ratio.
But I don't know which code is true for calculating.
My code is below.
img=imread('image.jpg');
if(size(img,3)>1)
img=rgb2gray(img);
end
SP=imnoise(img,'salt & pepper',0.1);
MDO = medfilt2(img);
MDSP = medfilt2(SP);
GO = imgaussfilt(img);
GSP = imgaussfilt(SP);
% 1) psnrMDSP = psnr(SP,MDO);
% 1) psnrGSP = psnr(SP,GO);
% 2) psnrMDSP = psnr(SP,MDSP);
% 2) psnrGSP = psnr(SP,GSP);
% Which number calculating is true 1 or 2 ?
% my aim is to get which filter is successful psnr values on this salt and pepper noise.

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 23 Jan 2021
Modifié(e) : KALYAN ACHARJYA le 23 Jan 2021
"% my aim is to get which filter is successful psnr values on this salt and pepper noise."
2nd One
If you check the format of the PSNR calculation you may get the answer
psnr_val=psnr(resultant_image,Noisy_image)
Or
psnr_val=psnr(resultant_image,reference_image)
Or
psnr_val=psnr(filtered_image,noisy_image)
Then this one to see the performance of medfilt2 and imgaussfilt filter on the particular noisy image. Here SP is the noisy imag, MDSP and GSP are the filtered images(on Noisy Image) using medfilt2 and imgaussfilt respectively.
% 2) psnrMDSP = psnr(SP,MDSP);
% 2) psnrGSP = psnr(SP,GSP);
More, then what does "1" means in the code
% 1) psnrMDSP = psnr(SP,MDO);
% 1) psnrGSP = psnr(SP,GO);
Here, if you carefully notice, here SP is the noisy image, on the other hand MDO and GO are the filtered images on the Original Image. Here in '1' applied the filters on original image, not the noisy image.
  1 commentaire
Ali Zulfikaroglu
Ali Zulfikaroglu le 23 Jan 2021
Thank you very much Mr Kalyan ACHARJYA

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by