如何计算图像末端的lbp码? [英] How to calculate the lbp codes at the ends of the images?
问题描述
例如,坐标为(1,1)的像素的lbp代码可以使用像素(0,0)进行计算; (0,1); (0,2); (1,2); (2,2); (2,1); (2,0); (1,0),但极值像素不具有这8个邻域像素,即,像素(0,0)仅具有3个邻域.
For example, the lbp code of the pixel with coordinate (1, 1) is possible to calculate it with the pixels (0, 0); (0, 1); (0, 2); (1, 2); (2, 2); (2, 1); (2, 0); (1, 0) but the pixels of the extremes do not have those 8 neighborhood pixels, that is, the pixel (0, 0) only has 3 neighbors.
出现这个问题是因为我已经使用sicikit图像获得了LBP图像,代码如下:
This question comes to me because I have obtained the LBP image using sicikit image, the code is as follows:
lbp = feature.local_binary_pattern (gray, 8, 1, 'ror')
然后我打印了灰色图像的值并得到了这些值:
Then I printed the values of the gray image and got these values:
[[185 185 190 ... 176 172 178]]
[183 180 181 ... 194 185 175]
[203 199 199 ... 201 193 179]
...
[205 188 182 ... 183 183 182]
[207 197 194 ... 193 190 186]
[206 201 201 ... 201 199 197]]
我还打印了LBP图像的值并得到了这些值:
I also printed the values of the LBP image and got these values:
[[ 1. 17. 1. ... 15. 31. 1.]
[ 27. 255. 127. ... 7. 7. 31.]
[ 0. 31. 31. ... 1. 31. 15.]
...
[ 17. 31. 63. ... 63. 111. 31.]
[ 0. 31. 31. ... 15. 15. 7.]
[ 1. 25. 17. ... 0. 1. 1.]]
我知道,例如,右上角像素的lbp码是正确的,因为它提供的值为7,但是我不明白如何获得极限值的LBP码.谢谢.
I understand that, for example, the lbp code of the pixels on the top right is correct since it provides a value of 7 but I do not understand how the LBP codes of the extremes are obtained. Thanks.
推荐答案
The function skimage.feature.local_binary_pattern
performs zero padding under the hood. As a consequence of it the LBP codes are actually computed from the padded image:
[[ 0 0 0 0 ... 0 0 0 0]
[ 0 185 185 190 ... 176 172 178 0]
[ 0 183 180 181 ... 194 185 175 0]
[ 0 203 199 199 ... 201 193 179 0]
...
[ 0 205 188 182 ... 183 183 182 0]
[ 0 207 197 194 ... 193 190 186 0]
[ 0 206 201 201 ... 201 199 197 0]
[ 0 0 0 0 ... 0 0 0 0]]
在上图使用'ror'
方法时,与最左上角像素相对应的LBP为:
When you use the 'ror'
method on the image above, the LBP corresponding to the top left most pixel is:
0 0 0 0 0 0
0 185 185 >> 0 1 >> 00000001 >> 1
0 183 180 0 0 0
第一行第二个像素对应的LBP变为:
The LBP corresponding to the second pixel on the first row turns out to be:
0 0 0 0 0 0
185 185 190 >> 1 1 >> 00010001 >> 17
183 180 181 0 0 0
与最右上角像素相对应的LBP为:
The LBP corresponding to the top right most pixel is:
0 0 0 0 0 0
172 178 0 >> 0 0 >> 000000001 >> 1
185 175 0 1 0 0
...等等.
这篇关于如何计算图像末端的lbp码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!