简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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