上面是高斯滤波的原理:

在Matlab中高斯滤波主要涉及到下面两个函数:
函数: fspecial
函数: imfilter
代码:
- clear all;
- clc;
- %----------------------------------------------
- %对图像进行高斯滤波,并显示图像
- %----------------------------------------------
- %读进图像
- [filename, pathname] = uigetfile({'*.jpg'; '*.bmp'; '*.gif'; '*.png' }, '选择图片');
- %没有图像
- if filename == 0
- return;
- end
- Image = imread([pathname, filename]);
- [m, n, z] = size(Image);
- %转换为灰度图
- if z>1
- Image = rgb2gray(Image);
- end
- sigma = 1;
- gausFilter = fspecial('gaussian', [5,5], sigma);
- gaus= imfilter(Image, gausFilter, 'replicate');
- %显示图像-----------------------
- figure(1)
- subplot(1,2,1);
- imshow(Image);
- title('原图像');
- subplot(1,2,2);
- imshow(gaus);
- title('滤波后');
复制代码另外推荐一本书:《MATLAB图像处理实例详解》清华大学出版社。