PSNR CALCULATING MEDIAN FILTER GAUSSIAN FİLTER
3 views (last 30 days)
Show older comments
Ali Zulfikaroglu
on 23 Jan 2021
Commented: Ali Zulfikaroglu
on 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.
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 23 Jan 2021
Edited: KALYAN ACHARJYA
on 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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!