Borrar filtros
Borrar filtros

How should the output look like of the MSE of a median filtered image?

2 visualizaciones (últimos 30 días)
Nouf Alraisi
Nouf Alraisi el 2 de Dic. de 2023
Editada: DGM el 3 de Dic. de 2023
wanted to calculate both PSNR and the MSE between the reference image and the filtered (median) image, so I used this code. However, I am not sure if the output looks correct, please correct me if I am wrong.

Respuestas (2)

Image Analyst
Image Analyst el 2 de Dic. de 2023
You should use the built-in functions immse and psnr

DGM
DGM el 3 de Dic. de 2023
Editada: DGM el 3 de Dic. de 2023
The error image is as expected for the thing you did, but I don't know why you're doing it. You're comparing the filtered image with the unfiltered image. The unfiltered image in this case happens to be the original cameraman image without any added noise, so you're not observing any sort of noise removal. You're just observing the degree to which the clean image is altered. It should be expected that narrow details will be altered by the use of an indiscriminate median filter, hence the error being present in the narrow highlight regions.
Try increasing the size of the window used by the median filter and observe how it changes.
ref = imread('cameraman.tif');
A = medfilt2(ref,[11 11],'symmetric'); % see what happens
imshow([ref A])
sqim = (double(ref) - double(A)) .^ 2;
imshow(sqim, []);
mse = mean(sqim(:))
mse = 491.8676
% presumes image is uint8
% use 255 instead of 256 if you want to match psnr()
PSNR = 10 * log10(255^2 / mse)
PSNR = 21.2123
Alternatively, try adding some noise to a copy of the image and see how it changes.
ref = imread('cameraman.tif');
noisy = imnoise(ref,'salt & pepper',0.1);
A = medfilt2(noisy,[3 3],'symmetric');
imshow([noisy A])
sqim = (double(ref) - double(A)) .^ 2;
imshow(sqim, []);

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by