Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Tuning parameters for cv2.houghcircle() method ?

I am unable to get the desired parameters after applying the cv2.houghcircle() method

MY CODE:

import cv2
import numpy as np

planets = cv2.imread('E:/Users/msoni3/Desktop/solar.jpg')
#planets = cv2.resize(planets, (1000,600))
gray_img = cv2.cvtColor(planets, cv2.COLOR_BGR2GRAY)
#img = cv2.medianBlur(gray_img, 5)
img = cv2.GaussianBlur(gray_img, (3,3), 0)

cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,120,
                        param1=100,param2=35,minRadius=0,maxRadius=0)

circles = np.uint16(np.around(circles))

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

cv2.imwrite("planets_circles.jpg", planets)
cv2.imshow("HoughCirlces", planets)
cv2.waitKey()
cv2.destroyAllWindows()

MY INPUT IMAGE: image description

and my output is My Output