Hello, I'm working on a project where I need to test various <http://www.dict.cc/englisch-deutsch/various.html> methods to fit ellipses <http://www.dict.cc/englisch-deutsch/ellipses.html> as accurate as possible. The hough ellipse fit from scikit-image for my images with perfect Ellipses is quite inaccurate as you can see in the examples. The white ellipse is my edge image. The red are the fitted ones. <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg> <https://lh4.googleusercontent.com/-_e1EN1j0e1A/VPeI_gVKenI/AAAAAAAAAHU/_6yJ5gHw8_c/s1600/ellipse4.jpg> <https://lh4.googleusercontent.com/-76eRCwkROTk/VPeI9td-ZbI/AAAAAAAAAHM/XOY0d2iIOSk/s1600/ellipse3.jpg>Why is there always a offset <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg>although my source image has perfect ellipses? <http://www.dict.cc/englisch-deutsch/although.html> I tried to vary the parameters but without success. <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg> <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg> <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg>Thank you so far. <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg> <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg>best regards <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg> Arno <https://lh5.googleusercontent.com/-9LZJ3vPmnAU/VPeIuqOv-pI/AAAAAAAAAG8/oDeC5ySkTHE/s1600/ellipse1.jpg>
Hi Arno On Wed, Mar 4, 2015 at 2:44 PM, Arno Dietz <arnodietz86@googlemail.com> wrote:
I'm working on a project where I need to test various <http://www.dict.cc/englisch-deutsch/various.html> methods to fit ellipses <http://www.dict.cc/englisch-deutsch/ellipses.html> as accurate as possible. The hough ellipse fit from scikit-image for my images with perfect Ellipses is quite inaccurate as you can see in the examples. The white ellipse is my edge image. The red are the fitted ones.
Please provide us with a minimal code snippet, then we can see where the problem is. Thanks Stéfan
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
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@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@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
participants (3)
-
Arno Dietz
-
Kevin Keraudren
-
Stéfan van der Walt