How to calculate the lbp codes at the ends of the images?

时光怂恿深爱的人放手 提交于 2019-12-18 07:35:31

问题


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.

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]]

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.]]

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.


回答1:


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]]

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  

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  

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  

... and so on.



来源:https://stackoverflow.com/questions/54427999/how-to-calculate-the-lbp-codes-at-the-ends-of-the-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!