how to find the length and width of connected components

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 comentarios

darova
darova el 25 de Mzo. de 2020
Can you show something? Hard to suggest something without a picture
thanx for ur reply i solved that problem.
now i need to know how to "remove/separate the big connected regions from binary image", as i already label the connected components using bwlabel and draw the Bounding Boxes around connected components using regionprops and BoundingBox but the only thing i need to know is how to "remove/separate the big connected regions" as i want to seprate those regions that have length and width equall to humans from big regions.
Note: I don't want to use length and width constraints for doing the above thing neither i want to use area (blobmeasurments.area) for doing this. If you know some kind of algorithm for doing the above mention work then kindly share it will be very helpfull for me thanx. (please don't mention the built in matlab functions, as i need complete method for doing this, so plz give/suggest me an algorithm that i can apply for doing this).

Iniciar sesión para comentar.

Respuestas (2)

darova
darova el 26 de Mzo. de 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 comentarios

i appriciate your answer
please explain ,me this line [~,ix] = sort(area,'descend');
further i dont want to show big regions as i want to eliminate the big regions and show the remaining regions. (how i will do that?).
and it will be very helpfull for me if you suggest me some other technique (other then the area constraints) for doing the same thing.
thanx
by using your code i removed the big 3 regions like this "is this is the same way you want to tell me??"
[L,n] = bwlabel(z);
data = regionprops(L,'area');
area = cat(1,data.Area);
[~,ix] = sort(area,'descend');
L(L==ix(1))=0;
L(L==ix(2))=0;
L(L==ix(3))=0;
imshow(L);
that was good experience thanx..But again my Question was same because i don't want to use area constraints. please help me out of doing the same thing but without using area (or length or width constraints). thanx
  • 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?
i m just showing here the two biggest regions of my image (that i show by using your above mention technique) i want to eleminate these two big regions only in such a way that the rest of the small regions stays there but without using fix area or without giving any thershold value for this classification of big and small regions i want my programe to do that for me automatically (may be some pixel searching algorithm or template matching algorithm will help me but instead of lots of search i didn't find any thing helpfull that fulfill my purpose). if you know some technique/algorithm that do the same thing then let me know it will be very helpfull for me. thanx.
  • 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
i already used the graythersh in preprocessing steps now the problem which i m facing was abave that i mentioned i know Kmeans algo but using that i m only able to make clusters like connected components but how can i seprate big and small clusters without any thershold or fix value?
have no idea :(

Iniciar sesión para comentar.

Categorías

Preguntada:

el 25 de Mzo. de 2020

Respondida:

el 18 de Jun. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by