简体   繁体   English

Python:skimage gabor_kernel 大小与预期不符

[英]Python: skimage gabor_kernel size not as expected

I am using the gabor kernel method from the scikit-image library for checking the orientations of my intensity image.我正在使用 scikit-image 库中的 gabor 核方法来检查强度图像的方向。 According to the official documentation, it takes the following parameters:根据官方文档,它需要以下参数:

gabor_kernel(frequency, theta=0, bandwidth=1, sigma_x=None, sigma_y=None, n_stds=3, offset=0)

In my code, I am using the following code, so the size of the kernel is implicitly defined to 3.在我的代码中,我使用了以下代码,因此内核的大小被隐式定义为 3。

    from skimage.filters import gabor_kernel
    frequency = (np.pi) / (2 * np.sqrt(2))
    theta = 0
    gkernel = gabor_kernel(frequency, theta=theta)
    print('theta=%d,\nfrequency=%.2f' % (theta * 180 / np.pi, frequency))
    print(gkernel)

在此处输入图片说明

I don t understand why the generated kernel is a matrix 15x15, when the size is set to 3.我不明白为什么生成的内核是一个矩阵 15x15,当大小设置为 3 时。

Thanks for your help, Sebastien感谢您的帮助,塞巴斯蒂安

The bandwidth option is a little mysterious.带宽选项有点神秘。 According to the documentation, "For fixed bandwidth, sigma_x and sigma_y will decrease with increasing frequency. This value is ignored if sigma_x and sigma_y are set by the user."根据文档,“对于固定带宽,sigma_x 和 sigma_y 将随着频率的增加而减少。如果 sigma_x 和 sigma_y 由用户设置,则该值将被忽略。” I recommend specifying sigma_x and sigma_y for direct control.我建议指定 sigma_x 和 sigma_y 以进行直接控制。

Another gotcha for me was the frequency.对我来说另一个问题是频率。 It has units of inverse pixels.它具有逆像素单位。 So it's more straightforward to specify a wavelength in pixels, and then frequency=1/wavelength.所以以像素为单位指定波长更直接,然后频率=1/波长。 For example, if your wavelength is 10, using frequency = 1/10 will mean that the signal completes 1 full cycle in 10 pixels.例如,如果您的波长为 10,则使用频率 = 1/10 将意味着信号在 10 个像素中完成 1 个完整周期。 Because of the way it's defined here, you don't need to worry about pi factors.由于此处定义的方式,您无需担心 pi 因素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM