为什么scikit-image中的local_binary_pattern函数为不同的模式提供相同的值?

Pet*_*ter 5 python numpy feature-extraction scikit-image lbph-algorithm

local_binary_pattern在scikit-image包中使用该函数.我想计算半径为1的8个邻居的旋转不变均匀LBP.这是我的Python代码:

import numpy as np
from skimage.feature import local_binary_pattern

image = np.array([[150, 137, 137, 146, 146, 148],
                  [145, 144, 144, 144, 142, 144],
                  [149, 144, 144, 143, 153, 147],
                  [145, 144, 147, 150, 145, 150],
                  [146, 146, 139, 148, 144, 148],
                  [129, 139, 142, 150, 146, 140]]).astype(np.uint8)

lbp = local_binary_pattern(image, 8, 1, "uniform")

print("image =")
print(image)
print("lbp =")
print(lbp)
Run Code Online (Sandbox Code Playgroud)

这是输出

image =
[[150 137 137 146 146 148]
 [145 144 144 144 142 144]
 [149 144 144 143 153 147]
 [145 144 147 150 145 150]
 [146 146 139 148 144 148]
 [129 139 142 150 146 140]]
lbp =
[[ 0.  5.  5.  1.  9.  0.]
 [ 9.  6.  9.  9.  8.  9.]
 [ 0.  8.  6.  8.  0.  3.]
 [ 9.  7.  1.  0.  7.  0.]
 [ 1.  1.  8.  9.  7.  1.]
 [ 3.  4.  9.  0.  2.  3.]]
Run Code Online (Sandbox Code Playgroud)

令我困惑的是,一些相同的值lbp不对应于相同的统一模式.例如,lbp[1, 1]并且lbp[2, 2]都是6,但对LBP image[1, 1]是:

1 0 0
1 x 1
1 1 1
Run Code Online (Sandbox Code Playgroud)

LBP image[2, 2]是:

1 1 1
1 x 0
1 1 1
Run Code Online (Sandbox Code Playgroud)

在基于值的情况下lbp,我假设local_binary_pattern函数使用'大于或等于'来与邻居进行比较.

LBP image[1, 1]和LBP image[2, 2]均匀.但是怎么可能image[1, 1]并且image[2, 2]具有相同的LBP值?

小智 3

旋转不变的 LBP 不直接使用邻居的像素值,而是使用在圆上插值的值(用于旋转不变性)。请参阅https://github.com/scikit-image/scikit-image/blob/master/skimage/feature/_texture.pyx#L156

另请参阅原始 LBP 论文http://vision.stanford.edu/teaching/cs231b_spring1415/papers/lbp.pdf,其中提到“不完全落在像素中心的邻居的灰度值是通过插值估计的”。