Matlab图像处理-图像去噪边缘增强


结合【中值滤波,均值滤波,高斯滤波】和【laplacian算子,sobel算子。prewitt算子】对图片进行去噪和边缘增强处理。通过视觉对比和MSE/SNR/PSNR数值对比,得到9种组合的处理效果。
资源截图
代码片段和文件信息
clc
clear all
close all
img = imread(‘testPic.tif‘);
img=img(1:128*161:128*16);
imwrite(img‘Source0.tif‘)
%% 均值滤波部分
figure(1);
subplot(345)
subimage(img);
title(‘原始图像‘);
Byave = filter2(fspecial(‘average‘3)img)/255; %进行3*3均值滤波
%空域锐化
p1 =fspecial(‘sobel‘);
subplot(342)
add1 =imfilter(Byavep1);
out1=add1+Byave;
subimage(out1);
title(‘sobel锐化结果(均值滤波)‘);
[SNRMSEPSNR]=getSNR(imgout1);
fprintf(‘均值滤波+sobel算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
subplot(343)
p2 =fspecial(‘prewitt‘);
add2 =imfilter(Byavep2);
out2=add2+Byave;
subimage(out2);
title(‘prewitt锐化结果(均值滤波)‘);
[SNRMSEPSNR]=getSNR(imgout2);
fprintf(‘均值滤波+prewitt算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
subplot(344)
p3 =fspecial(‘laplacian‘);
add3 =imfilter(Byavep3);
out3=add3+Byave;
imwrite(out3‘均值滤波+laplacian算子锐化.tif‘);
subimage(out3);
title(‘laplacian锐化结果(均值滤波))‘);
[SNRMSEPSNR]=getSNR(imgout2);
fprintf(‘均值滤波+laplacian算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
%% 中值滤波部分
Bymed=medfilt2(img[33]);
%空域锐化
p1 =fspecial(‘sobel‘);
subplot(346)
add1 =imfilter(Bymedp1);
out1=add1+Bymed;
subimage(out1);
title(‘sobel锐化结果(中值滤波)‘);
[SNRMSEPSNR]=getSNR(imgout1);
fprintf(‘中值滤波+sobel算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
subplot(347)
p2 =fspecial(‘prewitt‘);
add2 =imfilter(Bymedp2);
out2=add2+Bymed;
subimage(out2);
title(‘prewitt锐化结果(中值滤波)‘);
[SNRMSEPSNR]=getSNR(imgout2);
fprintf(‘中值滤波+prewitt算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
subplot(348)
p3 =fspecial(‘laplacian‘);
add3 =imfilter(Bymedp3);
out3=add3+Bymed;
imwrite(out3‘中值滤波+laplacian算子锐化.tif‘);
subimage(out3);
title(‘laplacian锐化结果(中值滤波)‘);
[SNRMSEPSNR]=getSNR(imgout3);
fprintf(‘中值滤波+laplacian算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
%% 高斯滤波部分
W = fspecial(‘gaussian‘[33]1); 
Bygaussian = imfilter(img W ‘replicate‘);
 p1 =fspecial(‘sobel‘);
subplot(3410)
add1 =imfilter(Bygaussianp1);
out1=add1+Bygaussian;
subimage(out1);
title(‘sobel锐化结果(高斯滤波)‘);
[SNRMSEPSNR]=getSNR(imgout1);
fprintf(‘高斯滤波+sobel算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
subplot(3411)
p2 =fspecial(‘prewitt‘);
add2 =imfilter(Bygaussianp2);
out2=add2+Bygaussian;
subimage(out2);
title(‘prewitt锐化结果(高斯滤波)‘);
[SNRMSEPSNR]=getSNR(imgout2);
fprintf(‘高斯滤波+prewitt算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)
subplot(3412)
p3 =fspecial(‘laplacian‘);
add3 =imfilter(Bygaussianp3);
out3=add3+Bygaussian;
imwrite(out3‘高斯滤波+laplacian算子锐化.tif‘);
subimage(out3);
title(‘laplacian锐化结果(高斯滤波)‘);
[SNRMSEPSNR]=getSNR(imgout3);
fprintf(‘高斯滤波+laplacian算子锐化:
SNR:%f
MSE:%f
PSNR:%f
‘SNRMSEPSNR)


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2897  2020-11-07 21:56  图像锐化ounderenhence.m
     文件         302  2020-11-07 20:41  图像锐化getSNR.m
     文件    37748946  2020-11-07 18:50  图像锐化 estPic.tif

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)