Counting the pixels within a circle detected in an image
Show older comments
Hi everyone.
Based on this image,
Using Hough Transformation, I managed to detect many circles. But I require only the middle circle detected around the pupil. There are several methods that I was thinking, that could remove the other circles.
For example,
1) counting the number of black pixels within the circle and the one with the most is the pupil. 2) taking the white pixels along the circumference of the pupil. the one with the most white pixels is the pupil.
I was thinking number 2 would be a more accurate solution. Hence, how do I count the number of white pixels?
Thank you!
Accepted Answer
More Answers (1)
Image Analyst
on 23 Dec 2011
0 votes
I think you should look at what you said: "require only the middle circle." Now since you placed those circles, you know where the centers are. So you simply take the center that is closest to (numberOfRows/2, numberOfColumns/2). It's as simple as that, assuming the circle you want is the one closest to the middle of the image.
6 Comments
Ivan
on 27 Dec 2011
Image Analyst
on 27 Dec 2011
Well why are you getting so many false positives in the first place? Maybe you can adjust the Hough parameters to get fewer. The ones it's getting don't all look right. Maybe you should just threshold on intensity and look for circular regions? Once you have your regions, do some size filtering (see my BlobsDemo File Exchange for a tutorial), and some circularity filtering and then measure the intensity of what's left.
measurements = regionprops(labeledImage, grayImage, 'MeanIntensity');
(You need > R2008a - if you don't see BlobsDemo for code to work with earlier/all versions)
The darkest one will be the pupil.
Ivan
on 28 Dec 2011
Ivan
on 4 Jan 2012
Image Analyst
on 12 Jan 2012
I didn't give a demo. Upload your image to tinypic.com and your code for finding the circle locations.
Ivan
on 17 Jan 2012
Categories
Find more on Image Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!