How do I detect the ellipses in the image attached?

This is a ring type target which I need to auto-detect and number. Currently I am trying to fit ellipse which is failing because I get all four connected components as separate ellipses.
What should be a robust strategy to detect the outer, the inner and the inner most ellipse so as to be able to detect code of the target?
In actual scenario, I will have many more targets like this in a single image, which will appear distorted depending upon the location of viewing camera.

Answers (1)

Use bwconvhull() to get the convex hull of the whole set of objects. That will work better, but not perfect because you're missing a quadrant.

7 Comments

Dear 'image analyst' many thanx for your quick reply. I find that the bwconvhull function is not in my matlab R2012a..is that true?
Fitting isnt a problem since I am able to fit circle and ellipses easily. The question is HOW DO I SAMPLE POINTS IN THE IMAGE SO THAT I CAN FIT AND FIND THE THREE ELLIPSES IN THE ATTACHED IMAGE?
You can use bwboundaries(), then put all the coordinates into convhull() to get the outermost ones. Then do your fit. You can also put them into plot() or poly2mask() if you want to see which points are on the convex hull.
This is how the result looks after applying your suggestions. Red shows convexhull on segmentted blue points. The green curve shows the fitted ellipse on convex-hull. I think your suggestion has definitely helped me 'IA', TY. How to detect all THREE ellipses in the image? And as I said I have many more in the same image. How to go about them?
I am pasting another example here
For this, I need to detect all 6 ellipses INDEPENDENTLY.
You need to use the FAQ to fit an ellipse to the boundary points. You already have the outer one (don't worry about the line connecting the points). You just need to get those coordinates for the other two ellipses. To get the center circular blobs, you can filter based on circularity (perimeter squared/(4*pi*area)) or Solidity. Not sure what the other one is but maybe it's the inner boundary of the outer sectors. You can get those by finding coordinates not on the first convex hull and not in the center blobs.
Ashutosh's "Answer" moved here to a comment since he incorrectly put this follow up question as an "Answer" (which it's not), and then "Accepted" it (for some reason). I deleted that answer and moved it here.
How do I assess the quality of blob detection?
I have this image containing ellipses. I need to find precise centers for all the ellipses (accuracy of order of 0.01 pixel).
I am using centroid finding and ellipse fitting algorithms to detect them and mark them. When I plot, I find that both of them are within .5 pixel but not sure which one is correct?
1) What method is best to get accuracies of order of 0.01 px ? 2) How do I say that my algorithm indeed achieved 0.01 px of accuracy?
please tell me statistical techniques to do so. I want to quantify.
Absolutely correct Analyst.My mistake.
You can't know the accuracy unless you have some "ground truth." I only told you one method: find the boundary points, then fit it to an ellipse. I don't know what you did after that for your second method. Did you then use poly2mask() to make a binary image and find the centroid with regionprops()?

Sign in to comment.

Asked:

on 6 Jul 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!