python - Detecting array of circles using Hough Circle Transform -
i trying observe circles in array. accomplish using hough circle transform. able observe 100% circles in array there lot many false positives , when rid of false positives not able observe 100% circles. when alter dp parameter 1 in code given below false positives gone , when maintain 3 there many false positives 100% detection. 100% detection 0 or few false positives. best approach this.
import cv2 import cv2.cv cv import numpy np img = cv2.imread('test1.tiff',0) cimg = cv2.cvtcolor(img,cv2.color_gray2bgr) circles = cv2.houghcircles(img, cv.cv_hough_gradient,3,15, param1=70 ,param2=17,minradius=1,maxradius=10) circles = np.uint16(np.around(circles)) in circles[0,:]: # draw outer circle cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) cv2.imshow('detected circles',cimg) cv2.imwrite("output15.jpg", cimg) cv2.waitkey(0) cv2.destroyallwindows() here there sample image:
since circles, , dark, why not filter them out morphological disk , subtract original image filtered 1 responses? morphology isn't particularly fast, faster hough. you'd dilate background (with disk shaped) until black gone, subtract original image that. threshold. can size filtering eliminate tiny scraps through.
given application, don't think hough strongest choice, unless school project.
python matlab opencv image-processing computer-vision
No comments:
Post a Comment