Re: hough ellipse fit inaccurate?
Well, there is not reason to use `fit ellipse` from OpenCV, you can use `skimage.measure.EllipseModel`.
On Mar 5, 2015, at 5:38 PM, Kevin Keraudren <kevin.keraudren@googlemail.com> wrote:
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/_...
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
-- 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.
Hi Kevin and Johannes, no the accuracy parameter has no effect on my measure accuracy. Yes I tried opencv fitellipse and it is much more accurate. But I want to test several methods and I heard that the hough transform is quite robust. The eyeball is a sphere and the Pupil a flat circle on the flat white plane. Since I view the circle from different angles it always appears <http://www.dict.cc/englisch-deutsch/appears.html> as a ellipse. So circle detection is not an option. Ok Thank you..it seams the skimage hough ellipse fit just isn't that accurate. @Johannes: I tried the EllipseModel with ransac from your link today and I like it very much. But I have some problems with greater angles. I always have a set of 25 images where the eye is looking at different targets on a display. I plot the difference between the true center and the measured center in one error diagram (see images). When the camera is located directly in front of the eye, so the angles are not to big, it works fine with low errors (see image 1). But when I move the camera down so that the pupil appear more elliptical I always get some outlier <http://www.dict.cc/englisch-deutsch/outlier.html>s with bigger errors like Point 2, 7, 12, etc. (see image 2). I tried to vary the parameters (min_samples, residual_threshold and max_trials) but there are always some outliers, but ever <http://www.dict.cc/englisch-deutsch/every.html>y time <http://www.dict.cc/englisch-deutsch/time.html> at different images. Do you have an idea where this comes from? Thank you so far. Kind regards Arno
Hi Arno, So, I just figured, that there was a bug in the most recent addition of RANSAC. The iteration terminated early, even if stop_probability was set to 1. Should be fixed in https://github.com/scikit-image/scikit-image/pull/1411 You may want to update your local installation with that changeset, and let RANSAC run for a sufficient number of iterations to get reliable estimates. Best, Johannes
On Mar 5, 2015, at 7:22 PM, Arno Dietz <arnodietz86@googlemail.com> wrote:
Hi Kevin and Johannes,
no the accuracy parameter has no effect on my measure accuracy. Yes I tried opencv fitellipse and it is much more accurate. But I want to test several methods and I heard that the hough transform is quite robust. The eyeball is a sphere and the Pupil a flat circle on the flat white plane. Since I view the circle from different angles it always appears as a ellipse. So circle detection is not an option. Ok Thank you..it seams the skimage hough ellipse fit just isn't that accurate.
@Johannes: I tried the EllipseModel with ransac from your link today and I like it very much. But I have some problems with greater angles. I always have a set of 25 images where the eye is looking at different targets on a display. I plot the difference between the true center and the measured center in one error diagram (see images). When the camera is located directly in front of the eye, so the angles are not to big, it works fine with low errors (see image 1). But when I move the camera down so that the pupil appear more elliptical I always get some outliers with bigger errors like Point 2, 7, 12, etc. (see image 2). I tried to vary the parameters (min_samples, residual_threshold and max_trials) but there are always some outliers, but every time at different images. Do you have an idea where this comes from?
Thank you so far.
Kind 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. <ellipse_errors1.jpg><ellipse_errors2.jpg>
Hi Johannes, thank you for your support. I have just recognized I have installed scikit-image 0.10.1, since I use Anaconda. How can I update scikit-image to 0.11? And how to update the changeset you mentioned? Can I just replace the files in "..\Anaconda\Lib\site-packages\skimage" ? Sorry I'm a beginner in programming. Best regards, Arno
Ok I just downloaded the latest version from "https://github.com/scikit-image/scikit-image/zipball/master" and run "pip install .". Then I changed the files "fit.py", "test_fit.py" and "_geometric.py" from your github link. Is this correct? It doesn't seem to solve my probleme since I still have some outliers (see Image). Regards, Arno
For how many iterations are you running RANSAC?
On Mar 7, 2015, at 6:19 AM, Arno Dietz <arnodietz86@googlemail.com> wrote:
Ok I just downloaded the latest version from "https://github.com/scikit-image/scikit-image/zipball/master" and run "pip install .". Then I changed the files "fit.py", "test_fit.py" and "_geometric.py" from your github link. Is this correct? It doesn't seem to solve my probleme since I still have some outliers (see Image).
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. <ransac_ellipse_outlier.png>
Another question: Is it still random images for which you see the outliers?
On Mar 7, 2015, at 8:10 AM, Johannes Schoenberger <jsch@demuc.de> wrote:
For how many iterations are you running RANSAC?
On Mar 7, 2015, at 6:19 AM, Arno Dietz <arnodietz86@googlemail.com> wrote:
Ok I just downloaded the latest version from "https://github.com/scikit-image/scikit-image/zipball/master" and run "pip install .". Then I changed the files "fit.py", "test_fit.py" and "_geometric.py" from your github link. Is this correct? It doesn't seem to solve my probleme since I still have some outliers (see Image).
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. <ransac_ellipse_outlier.png>
-- 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.
Do you mean the max_trials parameter? At the moment I use these: "model, inliers = measure.ransac(coords, measure.EllipseModel, min_samples=10, residual_threshold=1, max_trials=100)" I varied these parameters (min_samples=5 to 40, residual_threshold=0.005 to 10, max_trials=10 to 400) but with no success. The images with outliers remain the same with equal parameters but with different parameters the outliers appear on different images. Sometimes there also appear a warning message but in this case it is actually random, when it occurs: C:\Anaconda\lib\site-packages\scipy\optimize\minpack.py:419: RuntimeWarning: Number of calls to function has reached maxfev = 2600. warnings.warn(errors[info][0], RuntimeWarning) Another interesting fact, when I use a starburst algorithm (like this <http://www.frontiersin.org/files/Articles/2035/fnins-04-00193-HTML/image_m/fnins-04-00193-g002.jpg>) to detect my points for ellipse fitting instead of the canny edge detector, it seems to work fine mostly without outliers. I think the only difference is, that my starburst algorithm generates much less points (about 300) then canny. Regards, Arno
No, that’s not good. You need 5 points to estimate an ellipse model, and you should stick to the minimum parameters with RANSAC. Otherwise, you have to sample exponentially more to converge to a confident correct solution. Try something like: min_samples=5, max_trials>200 (depending on the outlier ratio of your edge points this may have to increase significantly), residual_threshold>2 (depending on the spread of your edge points, excluding the outlier points) Hope this helps, otherwise the only thing that helps would be to share your images and a code snippet. Best, Johannes
On Mar 7, 2015, at 8:32 AM, Arno Dietz <arnodietz86@googlemail.com> wrote:
Do you mean the max_trials parameter? At the moment I use these: "model, inliers = measure.ransac(coords, measure.EllipseModel, min_samples=10, residual_threshold=1, max_trials=100)" I varied these parameters (min_samples=5 to 40, residual_threshold=0.005 to 10, max_trials=10 to 400) but with no success. The images with outliers remain the same with equal parameters but with different parameters the outliers appear on different images.
Sometimes there also appear a warning message but in this case it is actually random, when it occurs: C:\Anaconda\lib\site-packages\scipy\optimize\minpack.py:419: RuntimeWarning: Number of calls to function has reached maxfev = 2600. warnings.warn(errors[info][0], RuntimeWarning)
Another interesting fact, when I use a starburst algorithm (like this) to detect my points for ellipse fitting instead of the canny edge detector, it seems to work fine mostly without outliers. I think the only difference is, that my starburst algorithm generates much less points (about 300) then canny.
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.
Okay. But I also tried your parameters without success. It was hard work but I created a minimal example from my code (see attachment). It takes quite a long time to run but I would be really thankful <http://www.dict.cc/englisch-deutsch/thankful.html> if you could take a look. regards, Arno
I tried to run this, but I get: Traceback (most recent call last): File "ellipse_fit.py", line 41, in <module> true_coords = pickle.load(file) ImportError: No module named multiarray
On Mar 7, 2015, at 11:30 AM, Arno Dietz <arnodietz86@googlemail.com> wrote:
Okay. But I also tried your parameters without success. It was hard work but I created a minimal example from my code (see attachment). It takes quite a long time to run but I would be really thankful if you could take a look.
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. <ransac_ellipse_fit.zip>
Hm I don't know. Do you have the file "true_coords.pickle" in the directory? So I think the simplest way is to post the true coordinates here so you can just copy and paste instead of loading it. true_coords = np.float32([[116.16552734, 56.91558838], [119.50671387, 50.36520386], [120.07568359, 47.97659302], [118.15393066, 51.35003662], [113.87670898, 58.54443359], [115.45068359, 67.83599854], [121.19805908, 61.79907227], [122.86755371, 58.47949219], [122.07769775, 59.83483887], [117.28759766, 65.25402832], [118.67297363, 74.89511108], [123.27319336, 70.87173462], [124.70935059, 69.62966919], [122.70861816, 70.76901245], [116.82958984, 76.34967041], [118.11944580, 85.86563110], [124.74987793, 82.02990723], [127.60803223, 80.19348145], [125.04113770, 81.24456787], [120.22363281, 83.61611938], [122.88574219, 93.01083374], [128.35363770, 91.51263428], [129.56744385, 89.71978760], [126.35644531, 92.14715576], [120.37841797, 93.98809814]])
I just looked at it, and it seems like this is caused by canny - you probably want to focus on optimizing that part. (0.4px error is also not that bad)
On Mar 7, 2015, at 2:48 PM, Arno Dietz <arnodietz86@googlemail.com> wrote:
Hm I don't know. Do you have the file "true_coords.pickle" in the directory? So I think the simplest way is to post the true coordinates here so you can just copy and paste instead of loading it.
true_coords = np.float32([[116.16552734, 56.91558838], [119.50671387, 50.36520386], [120.07568359, 47.97659302], [118.15393066, 51.35003662], [113.87670898, 58.54443359], [115.45068359, 67.83599854], [121.19805908, 61.79907227], [122.86755371, 58.47949219], [122.07769775, 59.83483887], [117.28759766, 65.25402832], [118.67297363, 74.89511108], [123.27319336, 70.87173462], [124.70935059, 69.62966919], [122.70861816, 70.76901245], [116.82958984, 76.34967041], [118.11944580, 85.86563110], [124.74987793, 82.02990723], [127.60803223, 80.19348145], [125.04113770, 81.24456787], [120.22363281, 83.61611938], [122.88574219, 93.01083374], [128.35363770, 91.51263428], [129.56744385, 89.71978760], [126.35644531, 92.14715576], [120.37841797, 93.98809814]])
-- 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.
It may be a good idea to upsample your image before doing canny, because edges lie in between pixels, and can only be accurately marked with enough resolution.
participants (3)
-
Arno Dietz
-
Johannes Schoenberger
-
Stéfan van der Walt