【发布时间】:2016-12-24 23:16:00
【问题描述】:
我正在使用 scikit-image 包中的 local_binary_pattern 函数。我想计算半径 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)
这是输出
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.]]
让我感到困惑的是lbp 中的某些相同值不对应于相同的统一模式。比如lbp[1, 1]和lbp[2, 2]都是6,但是image[1, 1]的LBP是:
1 0 0
1 x 1
1 1 1
image[2, 2] 的 LBP 是:
1 1 1
1 x 0
1 1 1
根据lbp 中的值,我假设local_binary_pattern 函数使用“大于或等于”来与邻居进行比较。
image[1, 1] 和 image[2, 2] 的 LBP 都是统一的。但是image[1, 1] 和image[2, 2] 怎么会有相同的 LBP 值呢?
【问题讨论】:
标签: python numpy feature-extraction scikit-image lbph-algorithm