本人最近在开设本科生的《数字图像处理》课程,对于课程中遇到的空域滤波算法,也做了一次从研究生毕业以来最深入的分析。对于图像处理的基础知识来说,本人觉得搞懂算法原理,能在matlab中熟练利用工具函数解决问题,对于本科阶段已经足够了。至于编写自定义函数来实现和内置函数类似的功能,稍微有那么一点画蛇添足。
比如,空域滤波使用到的imfilter()函数,它的命令参数就值得深入研究一下。imfilter的基本格式是:
B = imfilter(A,h)
B = imfilter(A,h,options,...)
说的直白一点,就是利用掩模进行图像卷积的过程。但是对模板照顾不到的边界该怎样处理呢?matlab的官方文档提供的说明是一种名叫“Option padding”的选项,并提供了三种参数可供选择:
Padding Options | |
numeric scalar, | Input array values outside the bounds of the array are assigned the value |
| Input array values outside the bounds of the array are computed by mirror-reflecting the array across the array border. |
| Input array values outside the bounds of the array are assumed to equal the nearest array border value. |
| Input array values outside the bounds of the array are computed by implicitly assuming the input array is periodic. |
字面意思上讲就是“指定值为X”、“对称”、“复制”和“循环”。后三种选项对应的图示如下(5*5掩模为例):
另外还有一些参数的调用方法如下: