码迷,mamicode.com
首页 > 编程语言 > 详细

用python实现LBP特征点计算

时间:2017-07-30 22:04:25      阅读:1875      评论:0      收藏:0      [点我收藏+]

标签:type   特征   name   window   code   rgb   .sh   pre   waitkey   

 1 import cv2
 2 import numpy as np
 3 
 4 
 5 def olbp(src):
 6     dst = np.zeros(src.shape,dtype=src.dtype)
 7     for i in range(1,src.shape[0]-1):
 8         for j in range(1,src.shape[1]-1):
 9             pass
10             center = src[i][j]
11             code = 0;  
12             code |= (src[i-1][j-1] >= center) << 7;  
13             code |= (src[i-1][j  ] >= center) << 6;  
14             code |= (src[i-1][j+1] >= center) << 5;  
15             code |= (src[i  ][j+1] >= center) << 4;  
16             code |= (src[i+1][j+1] >= center) << 3;  
17             code |= (src[i+1][j  ] >= center) << 2;  
18             code |= (src[i+1][j-1] >= center) << 1;  
19             code |= (src[i  ][j-1] >= center) << 0;  
20   
21             dst[i-1][j-1]= code;  
22     return dst
23 
24 
25 lena = cv2.imread(d:/lena.jpg)
26 cv2.namedWindow(lena)
27 cv2.imshow(lena, lena)
28 cv2.waitKey(0)
29 
30 gray = cv2.cvtColor(lena,cv2.COLOR_RGB2GRAY)
31 x = olbp(gray)
32 
33 cv2.namedWindow(olbp)
34 cv2.imshow(olbp, x)
35 cv2.waitKey(0)

 

用python实现LBP特征点计算

标签:type   特征   name   window   code   rgb   .sh   pre   waitkey   

原文地址:http://www.cnblogs.com/enigma19971/p/7260510.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!