Tuesday, 12 January 2016

Draw a circle around iris using hough circles using Python

import cv2
import numpy as np

img = cv2.imread('eye.jpg',0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,2,100,
                            param1=50,param2=30,minRadius=8,maxRadius=11)


for i in circles[0,:]:
    # draw the outer circle
    cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),1, cv2.LINE_AA)
    # draw the center of the circle
    #cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()

No comments:

Post a Comment