數字圖像和視頻處理的基礎-第5週中值濾波PSNR練習題

In this problem you will perform median filtering to enhance the quality of a noise corrupted image. Recall from the video lecture that median filtering is effective for removing "salt-and-pepper" noise from images. Follow the instructions below to complete this problem. (1) Download the noisy image from here. Load the noisy image into a MATLAB array and convert the type of the array from 8-bit integer 'uint8' to real number 'double'. Refer to MATLAB problems in previous homework if you need help with loading and converting images. Visualize the noisy image using the built-in MATLAB function "imshow". The function "imshow" takes as its argument either [0-255] for an 8-bit integer array (i.e., of type 'uint8'), or [0-1] for a normalized real-valued array (i.e., of type 'double'). To provide "imshow" with the correct argument, you would need either to "cast" your real-valued array into 'uint8', or normalize it by 255. (2) Perform 3x3 median filtering using the built-in MATLAB function "medfilt2". For this problem, the only argument you need to provide "medfilt2" with is the array you have created in step (1). Visualize the filtered image using "imshow". Remember to either cast the result to 'uint8' or normalize it before feeding it to "imshow". (3) Perform a second-pass median filtering on the filtered image that you have obtained from step (2). Visualize the two-pass filtered image. Compare it with the noisy input image and the 1-pass filtered image. (4) Download the noise-free image from here. Compute the PSNR values between (a) the noise-free image and the noisy input image, (b) the noise-free image and the 1-pass filtering output, and (c) the noise-free image and the 2-pass filtering output. Enter the three PSNR values in the box below. Enter the numbers to two decimal points.


clear;
clear all;
clear clc;

I = double(imread('noisy.jpg'));
imshow(I,[]);
I1 = medfilt2(I);
figure,imshow(I1,[]);
I2 = medfilt2(I1);
figure,imshow(I2,[]);
Ifree = double(imread('noisefree.jpg'));
[h w]=size(I);

B=8;                
MAX=2^B-1;
MES=sum(sum((Ifree-I).^2))/(h*w);     %均方差
PSNR1=10*log10(MAX*MAX/MES);           %峯值信噪比
MES=sum(sum((Ifree-I1).^2))/(h*w);     %均方差
PSNR2=10*log10(MAX*MAX/MES);           %峯值信噪比
MES=sum(sum((Ifree-I2).^2))/(h*w);     %均方差
PSNR3=10*log10(MAX*MAX/MES);           %峯值信噪比


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章