用于在Matlab中平滑图像的均值滤波器 [英] Mean filter for smoothing images in Matlab

查看:863
本文介绍了用于在Matlab中平滑图像的均值滤波器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Matlab中测试一些基本的图像处理技术。我需要测试和比较特别是两种类型的滤波器:均值滤波器和中值滤波器。

I need to test some basic image processing techniques in Matlab. I need to test and compare especially two types of filters: mean filter and median filter.

为了使用中值滤波来平滑图像,有一个很棒的函数 medfilt2 来自图像处理工具箱。平均滤波器有类似的功能吗?或者如何使用 filter2 函数创建均值过滤器?

To smooth image using median filtering, there is a great function medfilt2 from image processing toolbox. Is there any similar function for mean filter? Or how to use the filter2 function to create the mean filter?

对我来说最重要的事情之一就是有可能设置过滤器的半径。即对于中值滤波器,如果我想要[3 x 3]半径(掩码),我只需使用

One of the most important things for me is to have the possibility of setting radius of the filter. I.e. for median filter, if I want the [3 x 3] radius (mask), I just use

imSmoothed = medfilt2(img, [3 3]);

我想为平均过滤器实现类似的东西。

I would like to achieve something similar for mean filter.

推荐答案

h = fspecial('average', n);
filter2(h, img);

参见 doc fspecial
h = fspecial('average',n)返回平均滤波器。 n 是一个1乘2的向量,指定 h 中的行数和列数。

See doc fspecial: h = fspecial('average', n) returns an averaging filter. n is a 1-by-2 vector specifying the number of rows and columns in h.

这篇关于用于在Matlab中平滑图像的均值滤波器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆