程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Harris feature detection (implemented in Python)

編輯:Python

List of articles

    • 1.Opencv Feature scene
    • 2. features
    • 3.Harris feature detection
    • 4. Harris (Harris) Characteristic properties of corners
    • 5. Function explanation
    • 6. Code combat

1.Opencv Feature scene

(1) Image search : Search for ;
(2) jigsaw puzzle ;
(3) Image mosaic : Join two related graphs together ;


2. features

Image features refer to meaningful image areas , It's unique , Legibility , Like corners , Spots and high density areas .
Corner point : The most important feature is the corner ; The pixel corresponding to the maximum value of the gray gradient ; The intersection of two lines ; Extreme points ( The first derivative is the largest , The second derivative is 0)


3.Harris feature detection


 The first rectangle represents a flat area , Moving in all directions , The pixel value in the window does not change ;
 The second rectangle represents an edge feature (Edges), If you move vertically ( Gradient direction ), The pixel value will change ; If you move along the edge ( Parallel to the edge ) , Pixel values don't change ;
 The third picture is a rectangle , It's a corner (Corners), No matter which direction you move it , Pixel values can change a lot .


4. Harris (Harris) Characteristic properties of corners

 This algorithm is not sensitive to the change of brightness and contrast .
 Operators have rotation invariance .
 Operators do not have scale invariance .


5. Function explanation

cornerHarris(src, blockSize, ksize, k, dst=None, borderType=None)
Src: Input the original image ;
Blocksize: Detect the size of the window
Ksize: volume Sobel Size of product kernel ;
K: Weight factor , Empirical value , Usually take 0.02-0.04 Between .
Dst: Output image
borderType:⽤ It is used to infer a certain boundary pattern of external pixels of an image , Have default values BORDER_DEFAULT.


6. Code combat

import os
import cv2
# Read the picture
img=cv2.imread('images/HaLiSi.jpg')
# Zoom in and out
img=cv2.resize(src=img,dsize=(450,450))
# Go to grayscale
gray=cv2.cvtColor(src=img,code=cv2.COLOR_RGB2GRAY)
# Harris test
halisi=cv2.cornerHarris(src=gray,blockSize=2,ksize=3,k=0.03)
# Judge the corner “ quality ”
img[halisi>0.01*halisi.max()]=[0,255,0]
# Display images
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == '__main__':
print('Pycharm')


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved