How can I count the number of connected components in a map
Show older comments
I am working on a project which requires finding number of connected components in binary image of map. I applied bwconncomp() function but its giving the wrong result. The code I am using is :
A=imread('contours.jpg'); figure,imshow(A); title('Original Image'); n = bwconncomp(A,8) fprintf('\nnumber of components = %.0f\n',n.NumObjects);
output is coming as : number of components = 113
Please tell me where I am making mistake. I am new to MatLab.

1 Comment
Image Analyst
on 21 Sep 2015
How many do you see? All the contours are connected by the white frame, so that's 1. The 700 and 800 each have 3 individual blobs. So that's 7 in total. Is 7 what you want?
Accepted Answer
More Answers (0)
Categories
Find more on Explore and Edit Images with Image Viewer App in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!