how to find the length and width of connected components
Show older comments
hi everyone.
i want to know how to find the length and width of connected components as i already label the connected components using bwlabel and draw the boundries using regionprops and boundry but now the only thing i need to know is how to find the length and width of that drawn boundries(connected components). as i want to seprate those regions that have length and width equall to humans.
2 Comments
darova
on 25 Mar 2020
Can you show something? Hard to suggest something without a picture
QuestionsAccount
on 26 Mar 2020
Answers (2)
darova
on 26 Mar 2020
Use regionprops
If you used bwlabel, can't you just separate?
[L,n] = bwlabel(image);
data = regionprops(L,'area');
area = cat(1,data.Area);
[~,ix] = sort(area,'descend');
imshow(L==ix(1)) % show biggest region
pause(1)
imshow(L==ix(2)) % show second biggest region
7 Comments
QuestionsAccount
on 27 Mar 2020
QuestionsAccount
on 27 Mar 2020
darova
on 27 Mar 2020
- please explain ,me this line [~,ix] = sort(area,'descend');
array area has number of pixels (area) of each region. sort just sorts it in descent order (biggest first, smallest last)
You can remove a few region using for loop
for i = [1 2 4] % regions to remove
L(L==ix(i))=0;
end
- But again my Question was same because i don't want to use area constraints
Can you attach some images and show what are you trying to do?
QuestionsAccount
on 29 Mar 2020
darova
on 29 Mar 2020
- without giving any thershold value for this classification of big and small regions
Do your images differs a lot? You can try graythresh
I1 = im2bw(I,graythresh(I)); % binarization using mean theshold
I also heard something about kmeans (clustering) but dont know how it works
QuestionsAccount
on 2 Apr 2020
darova
on 2 Apr 2020
have no idea :(
Image Analyst
on 18 Jun 2020
0 votes
Try bwareafilt().
Categories
Find more on Labeling, Segmentation, and Detection 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!