Happy Shrimp
http://blog.csdn.net/lights_joy/
Welcome reprint, but please keep the author information
brisk is brief an improvement of the descriptors, compared to the brief python
First read the Image:
# Read Original image img = Cv2.imread (r ' F:\projects\src\opencv\images\cotton\39.gray.jpg ') plt.imshow (IMG)
then create a Brisk Feature Detectors:
# Create Brisk Detector brisk = Cv2. Brisk_create ()
Next, the features of the image are computed, and the prototype of this function is:
Help on built-in function Detectandcompute:detectandcompute (...) Detectandcompute (image, mask[, descriptors[, useprovidedkeypoints]), keypoints, descriptors
Call it to compute the feature point and display:
# Compute feature points and display (KPT, desc) = Brisk.detectandcompute (img, None) bk_img = img.copy () out_img = Img.copy () out_img = Cv2.drawkeypoin TS (bk_img, KPT, out_img) plt.figure (2) plt.imshow (out_img)
The result is this:
It seems that there is no direct help to our leaf recognition, we need to find the characteristic point.
rotate the original image directly - Degree:
# Original image rotated 30 degrees Ang=np.pi/6rot_mat = Np.array ([[Np.cos (ANG), Np.sin (ANG), 0], [-np.sin (ANG), Np.cos (ANG), +]]) img_30 = Cv2.warpaffine (IMG, Rot_mat, (600,500)) Plt.figure (3) plt.imshow (img_30)
To calculate a new eigenvalue:
# Feature point Detection (kpt_30, desc_30) = Brisk.detectandcompute (img_30, None) bk_img = img_30.copy () out_img = Img_30.copy () out_img = Cv2 . drawkeypoints (Bk_img, kpt_30, Out_img) plt.figure (4) plt.imshow (OUT_IMG)
To do the matching of the feature points directly:
# feature points Match Matcher = Cv2. Bfmatcher () matches = Matcher.match (desc, desc_30) print (matches)
Finally, the matching results are shown in the image:
# Show matching results, show only the previous 5 points matches.sort (none, none, True) out_img = Cv2.drawmatches (img, KPT, img_30, Kpt_30, Matches[0:5], Out_ IMG) plt.figure (5) plt.imshow (out_img)
The matching effect is also disappointing.
??
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python image processing: Brisk feature detection