Hough circle transform to circular shadow

Viewed 627

I have an image in which I am trying to apply Hough circle transforms to the circular objects in view.

I am having difficulty finding a circle that fits the outer shadow of the cyclinder. What can be done to properly segment this shadow and easily fit a circle to it?

Code:

img = cv2.medianBlur(im,7)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

plt.imshow(cimg)
plt.show()

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,
                            param1=50,param2=150,minRadius=100,maxRadius=0)

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

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

    radius = i[2]
    print 'radius', radius, 'px'

plt.imshow(cimg)
plt.show()
2 Answers
Related