Hough Transform - Finding the center of the hough transform circles
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have been reading up quite a bit on Hough circles and how it can be used to detect the center and radius of a circular object. Although I understood how the transform works I am still not able to to understand how to get the center of a circle. The code snippet below is customized purely for coins.png in MATLAB. I tried it with a slightly more complex picture and it fails miserably. I am fixing the radius and then getting the accumulator matrix.
Code:
temp = accum;
temp(find(temp<40))=0; %Thresholding
imshow(temp,[0 max(temp(:))])
temp = imdilate(temp, ones(6,6)); %Dilating
imshow(temp,[0 max(max(temp))]);
temp = imerode(temp,ones(3,3)); %Eroding
imshow(temp,[0 max(max(temp))]);
s = regionprops(im2bw(temp),'centroid'); %Computing centroid
centroids = cat(1, s.Centroid);
I wanted to test the code out on a different picture and found this one on google. The Hough Transform produced a favorable result, but it's more overlapping than the previous case and my method fails.
Can someone suggest what the best method is to compute the centroid of the hough circle? I saw a lot of Hough circle transform codes in the Mathworks community, but I couldn't quite figure out how the centroid is being calculated.
0 Kommentare
Antworten (1)
David Young
am 13 Feb. 2015
If it helps at all, my version of the FEX circle HTs includes a demo which shows how to get the centres of the circles.
So does the documentation for imfindcircles, which should probably be the function of choice now that it is in the IPT.
Note, by the way, that the HT finds centres rather than centroids. (They are the same if a complete circle is visible, but if only part of the circle is visible the HT finds the actual centre, not the centroid of the visible part.)
If the demos don't help, please could you explain a little more what it is you don't understand - you're clear about how the HT algorithm works, right?
2 Kommentare
David Young
am 14 Feb. 2015
Well it's best to fix the radius value if you know in advance what radius you are looking for, so you may be doing the right thing there. If you are getting smaller circles than you want, then it must mean the radius you are looking for is too small. I'm not sure what you mean by getting small circles instead of a local max though - the local max would be in the accumulator array but the circles are in the image.
I'm not sure what you mean by having to find the centres. Both imfindcircles in the IPT and FEX contributions just give you the centre coordinates as outputs.
My code actually uses imregionalmax in one of the two methods it uses to locate peaks in the accumulator array, so that gives you an example of applying it.
Any help? Can you make your question more exact?
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!