I succesfully used the hough circle from scikit image to detect the central circle from some edge image like below (which is a zebrafish eye btw )
I tried then the hough ellipse to find the larger contour, but the computation time is way too long even for small images (like 30sec to 1 min per image). I know there are more parameters than for circle but I’m hoping some optimisation is possible.
I tried to play with the parameters to kind of constrain the detection but without much success.
Any tip ? Decreasing the amount of edges maybe ?
Otherwise I might try fitting an ellipse on the cloud of points (does not seem that simple though).
I tried fitEllipse from opencv too but using a thresholded image as input it returns an ellipse that encloses all the mask, yet the output of the thresholding is usually not as clean as the edge detection.
Below the code and some example data (in tiff).
WE00001—A001–PO01–LO001–CO6–SL010–PX16250–PW0040–IN0020–TM246–X014262–Y010963–Z212275–T1375384476.tif (28.1 KB)
import numpy as np from skimage.io import imread from skimage.transform import hough_ellipse, hough_circle edges = imread(r"C:\Users\Laurent Thomas\Desktop\EyeEdges\WE00002---A002--PO01--LO001--CO6--SL010--PX16250--PW0040--IN0020--TM246--X023272--Y010963--Z212275--T1375394459.tif") # Detect circles in the image print("Start Hough circle") try_radii = np.arange(30, 40, 1) resultCircle = hough_circle(edges, try_radii) # accumulator matrix print("Hough circle done") # Detect ellipse print("\nStart Hough ellipse") resultEllipse = hough_ellipse(edges, accuracy=25, threshold=100, min_size=100, max_size=120) print("Hough Ellipse done")