为什么内核大小应该是奇数? [英] Why should the size of the kernel be odd?

查看:132
本文介绍了为什么内核大小应该是奇数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在图像处理中使用均值过滤器时,为什么内核的大小应奇数?它的大小始终为 3x3 5x5 .有人可以解释原因吗?

When using the mean filter in image processing, why should the size of the kernel be odd? It Always takes a odd size as 3x3 or 5x5. Could anyone explain it with reasons?

推荐答案

内核不需要为奇数.定义一个偶数大小的内核是完全可能的.当内核大小为偶数时,哪个像素应该在原点就不太明显了,但这不是问题.您已经看到了大多数奇数大小的过滤器内核,因为它们围绕原点对称,这是一个很好的特性.

The kernel doesn't need to be odd. It's perfectly possible to define an even-sized kernel. When the kernel size is even, it is less obvious which of the pixels should be at the origin, but this is not a problem. You have seen mostly odd-sized filter kernels because they are symmetric around the origin, which is a good property.

这是MATLAB中的一个示例,其中我们使用4x4平均内核(均值过滤器)过滤图像:

Here is an example in MATLAB where we filter the image with a 4x4 averaging kernel (mean filter):

img = imread('cameraman.tif');
img = imfilter(img,fspecial('average',4));
imshow(img)

这篇关于为什么内核大小应该是奇数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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