首页 > 代码库 > 用python实现LBP特征点计算
用python实现LBP特征点计算
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特征点计算
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。