用python实现LBP特征点计算,, 1 import


 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             pass10             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 dst23 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特征点计算

评论关闭