hough ellipse fit inaccurate?

Kevin Keraudren kevin.keraudren at googlemail.com
Wed Mar 4 19:24:46 EST 2015


A second source of inaccuracy comes from your input ellipse: it is not a
perfect ellipse because you drew it using anti-aliasing.

On Thu, Mar 5, 2015 at 12:21 AM, Kevin Keraudren <
kevin.keraudren at googlemail.com> wrote:

> 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
>
>
>
> On Wed, Mar 4, 2015 at 11:49 PM, Arno Dietz <arnodietz86 at googlemail.com>
> wrote:
>
>>
>>  Ok sorry. Here is my code:
>>
>> 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()
>>
>>
>> I noticed, that the ellipse center is detected only in half pixel
>> accuracy. Maybe this is the Problem? Is there a possibility to get the
>> ellipse center with sub-pixel accuracy?
>>
>> regards Arno
>>
>>>  --
>> 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+unsubscribe at googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20150305/e303b4ed/attachment.html>


More information about the scikit-image mailing list