

Why is there always a offset although my source image has perfect ellipses? I tried to vary the parameters but without success.
Thank you so far.best regardsArno
from skimage import color
from skimage.filter import canny
from skimage.transform import hough_ellipse
from skimage.draw import ellipse_perimeter
from skimage import io
from skimage.viewer import ImageViewer
# load image
img = io.imread('ellipse.png')
cimg = color.gray2rgb(img)
# edges and ellipse fit
edges = canny(img, sigma=0.1, low_threshold=0.55, high_threshold=0.8)
result = hough_ellipse(edges, accuracy=4, threshold=25, min_size=47, max_size=60)
result.sort(order='accumulator')
# Estimated parameters for the ellipse
best = result[-1]
yc = int(best[1])
xc = int(best[2])
a = int(best[3])
b = int(best[4])
orientation = best[5]
# Draw the ellipse on the original image
cy, cx = ellipse_perimeter(yc, xc, a, b, orientation)
cimg[cy, cx] = (0, 0, 255)
# Draw the edge (white) and the resulting ellipse (red)
edges = color.gray2rgb(edges)
edges[cy, cx] = (250, 0, 0)
viewer = ImageViewer(edges)
viewer.show()
#yc = int(best[1])
#xc = int(best[2])
#a = int(best[3])
#b = int(best[4])
yc = int(round(best[1]))
xc = int(round(best[2]))
a = int(round(best[3]))
b = int(round(best[4]))
--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Arno,The first source of inaccuracy comes from your code, you need to round the values instead of truncating them:#yc = int(best[1])
#xc = int(best[2])
#a = int(best[3])
#b = int(best[4])
yc = int(round(best[1]))
xc = int(round(best[2]))
a = int(round(best[3]))
b = int(round(best[4]))
See resulting image attached.Kind regards,Kevin
A second source of inaccuracy comes from your input ellipse: it is not a perfect ellipse because you drew it using anti-aliasing.
Third, you could fit an ellipse using RANSAC. How does this approach work for you: http://stackoverflow.com/questions/28281742/fitting-a-circle-to-a-binary-image/28289147#28289147
--
Hi Arno,
Looking at the code, I would ask: Did your score improve by setting accuracy=1 ?
https://github.com/scikit-image/scikit-image/blob/master/skimage/transform/_hough_transform.pyx
Considering that you are asking for accuracy below half a pixel, I would not be surprised if the voting process of the Hough transform is not that accurate. A least-square fitting (Opencv fitellipse) might be more accurate than a voting process for a perfect ellipse.
Aren't the eyeball and the pupil both balls? If you slice them in any way, wouldn't you obtain disks? So why detecting elllipses and not circles? Maybe hough_circle will be more accurate.
Sorry I cannot provide any proof or certitude on how accurate hough_ellipse is.
Kind regards,
Kevin