MATLAB编程做图像处理类,新手,求大神帮助,不胜感激。

分别在2幅灰度图像中加入一定量的高斯噪声和椒盐噪声,噪声强度自定。然后采用3×3的均值滤波器和3×3中值滤波器分别对噪声图像进行处理,给出两种处理方法的峰值信噪比(PSN... 分别在2幅灰度图像中加入一定量的高斯噪声和椒盐噪声,噪声强度自定。然后采用3×3的均值滤波器和3×3中值滤波器分别对噪声图像进行处理,给出两种处理方法的峰值信噪比(PSNR)。 展开
 我来答
lliang77
2014-09-24 · TA获得超过104个赞
知道答主
回答量:189
采纳率:0%
帮助的人:130万
展开全部
function z = PSNR(x,y)% calculate PSNR of image
[M N] = size(x);
dx = im2double(x);
dy = im2double(y);
err = dx - dy;
MSE = sum(sum(err.^2)) / (M * N); %mean square error
z = 10*log10(255^2 / MSE);
end

clear all;
close all;
clc;
pic=imread('4.jpg');
data=rgb2gray(pic);
P1=imnoise(data,'gaussian',0.02) ;
P2=imnoise(data,'salt & pepper',0.02) ;
figure ;
subplot(1,3,1);imshow(data);title('原图');
subplot(1,3,2);imshow(P1);title('高斯加噪');
subplot(1,3,3);imshow(P2);title('椒盐加噪');

figure;
k1=medfilt2(data,[3 3]);
k2=medfilt2(P1,[3 3]);
k3=medfilt2(P2,[3 3]);
r1=PSNR(data, k1);
r2=PSNR(data, k2);
r3=PSNR(data, k3);
subplot(1,3,1);imshow(k1);title(['原图中值滤波' 'psnr:' num2str(r1)]);
subplot(1,3,2);imshow(k2);title(['高斯加噪中值滤波' 'psnr:' num2str(r2)]);
subplot(1,3,3);imshow(k3);title(['椒盐加噪中值滤波' 'psnr:' num2str(r3)]);

figure;
d1= filter2(fspecial('average',3),data)/255;
d2= filter2(fspecial('average',3),P1)/255;
d3= filter2(fspecial('average',3),P2)/255;
r1=PSNR(data, d1);
r2=PSNR(data, d2);
r3=PSNR(data, d3);
subplot(1,3,1);imshow(d1);title(['原图均值滤波' 'psnr:' num2str(r1)]);
subplot(1,3,2);imshow(d2);title(['高斯加噪均值滤波' 'psnr:' num2str(r2)]);
subplot(1,3,3);imshow(d3);title(['椒盐加噪均值滤波' 'psnr:' num2str(r3)]);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式