figure oriImg=imread('peppers.bmp');%读取并显示原有图像 subplot(1,2,1); imshow(oriImg); title ('原始图像');%显示原始图像 grayImg = rgb2gray(oriImg);%转成灰度图像 subplot(1,2,2); imshow(grayImg); title ('灰度图像');%显示灰度图像 figure %加入高斯噪声,使用邻域平均滤波 Inoise=imnoise(grayImg,'gaussian',0,0.02);%对图像加入高斯噪声 subplot(1,2,1); imshow(Inoise); title('加入高斯噪声后的图像');%显示高斯噪声图像 h=ones(3,3)/8; h(2,2)=0;%构造邻域窗口 filters=imfilter(Inoise,h);%邻域平均滤波 subplot(1,2,2); imshow(filters); title('8邻域平均滤波后的图像') figure %加入椒盐噪声,使用中值滤波 Inoise=imnoise(grayImg,'salt & pepper');%加入椒盐噪声 subplot(1,2,1); imshow(Inoise); title('加入椒盐噪声后的图像'); filters=medfilt2(Inoise,[5,5]);%中值滤波 subplot(1,2,2); imshow(filters); title('中值滤波
基于matlab的图像处理——高斯噪声&均值滤波,椒盐噪声&中值滤波
最新推荐文章于 2026-04-30 10:59:24 发布
本文详细介绍了如何使用MATLAB进行图像处理,包括去除高斯噪声的邻域均值滤波方法,以及消除椒盐噪声的中值滤波技术。通过实例展示了这两种滤波器的工作原理及其在实际应用中的效果。


1万+

被折叠的 条评论
为什么被折叠?



