필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Nouf Alraisi
Nouf Alraisi 2023년 12월 2일
편집: DGM 2023년 12월 3일
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.

답변 (2개)

Image Analyst
Image Analyst 2023년 12월 2일
You should use the built-in functions immse and psnr

DGM
DGM 2023년 12월 3일
편집: DGM 2023년 12월 3일
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, []);

태그

Community Treasure Hunt

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

Start Hunting!

Translated by