用python實現LBP特徵點計算

來源:互聯網
上載者:User

標籤: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             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特徵點計算

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.