My image is here:
i\'m looking for a better solution or algorithm to detect the
APPROACH 1:
As suggested by Miki, I was able to detect the ellipse in the given image using contour properties (in this I used the area property).
CODE:
#--- First obtain the threshold using the greyscale image ---
ret,th = cv2.threshold(gray,127,255, 0)
#--- Find all the contours in the binary image ---
_, contours,hierarchy = cv2.findContours(th,2,1)
cnt = contours
big_contour = []
max = 0
for i in cnt:
area = cv2.contourArea(i) #--- find the contour having biggest area ---
if(area > max):
max = area
big_contour = i
final = cv2.drawContours(img, big_contour, -1, (0,255,0), 3)
cv2.imshow('final', final)
This is what I obtained:
APPROACH 2:
You can also use the approach suggested by you in this case. Hough detection of ellipse/circle.
You have to pre-process the image. I performed adaptive threshold and obtained this:
Now you can perform Hough circle detection on this image.
Hope it is not a mouthful!! :D