- Binarize the image so that it's logical. binaryImage = grayImage > 128
- Call binaryImage = imclearborder(binaryImage) to get rid of the single line around the perimeter.
- Invert the image: binaryImage = ~binaryImage, so now black circles are white
- Call binaryImage = imclearborder(binaryImage) to get rid of the large (now white) background
- Call bwlabel: [labeledImage, numberOfCircles] = bwlabel(binaryImage). This gives you the count.
- Call measurements = regionprops(labeledImage) if you want other measurements
Counting objects in an image
조회 수: 93 (최근 30일)
이전 댓글 표시
Dear Researchers, I have a problem of counting objects in an image. Suppose I have the below image (below link)
which i got after segmentation.
how can I count the small circles in the middle of the image. Kindly suggest
Subrajeet
댓글 수: 0
채택된 답변
Image Analyst
2013년 1월 7일
편집: Image Analyst
2013년 1월 7일
댓글 수: 2
Image Analyst
2013년 1월 7일
편집: Image Analyst
2013년 1월 7일
It's just basic, elementary image segmentation via intensity thresholding. Nothing fancy at all. See updated instructions above.
추가 답변 (3개)
Thomas
2013년 1월 7일
편집: John Kelly
2017년 11월 8일
You could use techniques shown in many MATLAB image processing demos.
SANAHA PATHAN
2016년 7월 25일
i want to count number of silkworm eggs from this figure, i used L=Count(binaryfig) this command for counting number of objects ,this command works but i actually dont know what actually this command count,and result of this command is different every time
댓글 수: 3
anna
2016년 10월 5일
편집: anna
2016년 10월 5일
hey I segmented blue nuclei from a blood smear image using k means color segmentation. how can i count the number of segmented blue nuclei. could u please help me with the code for counting [ cant use imfindcircle because the segmented nuclei are not exactly cirlce in shape ]
Image Analyst
2016년 10월 8일
Beenish Ishtiaq
2021년 8월 3일
Need code for counting different shapes separatelly which shows each shape result respectively in different edit boxes in GUI matlab..
댓글 수: 2
Image Analyst
2021년 8월 3일
See my attached demos. I find that usually using findpeaks() to count the number of peaks in the plot of distance of perimeter from centroid works pretty well.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!