What are the properties in a BoundingBox from regionprops?
Mostrar comentarios más antiguos
I'm trying to figure out what coordinates are being stored from a BoundingBox. For instance
L=logical(bw);
box=regionprops(L,'Area', 'BoundingBox');
box(2)
And the output
ans =
Area: 127
BoundingBox: [10.5000 11.5000 10 19]
What are those 4 values? Is it the [top left, top right, bottom left, bottom right] coordinates?
2 comentarios
abdelrahim hashem
el 14 de En. de 2019
Please Sir, why the values of the two components x and y is real values? Also, the last two values width and heigh are integer values?
Walter Roberson
el 14 de En. de 2019
There is the question of whether coordinates represent pixel centers or pixel edges.
Respuesta aceptada
Más respuestas (2)
elvis okacha
el 12 de Abr. de 2019
Editada: Walter Roberson
el 12 de Abr. de 2019
I am trying to find length and width.is this ok?:
I=Imread(filename)
Info=imfinfo(filename)
Thres=graythresh(I)
I2=~(im2bw(I,thresh))
cmp=bwconncomp(I2)
s=regionprops(cmp,'BoundingBox')
x=s.BoundingBox(3)
y=s.BoundingBox(4)
res=info.ResolutionUnit
resX=info.XResolutionUnit
resY=info.YResolutionUnit
3 comentarios
elvis okacha
el 12 de Abr. de 2019
Error 'field reference for multiple structure elements that is followed by more reference blocks is an error
Walter Roberson
el 12 de Abr. de 2019
Your image has multiple regions, so s is returning a nonscalar structure.
bb = vertcat(s.BoundingBox);
x = bb(:,1);
y = bb(:,2);
width = bb(:,3);
height = bb(:,4);
These will each be vectors, reflecting the fact that you have multiple regions.
elvis okacha
el 13 de Abr. de 2019
Thanks
SOURABH BHATTACHARYA
el 22 de En. de 2022
Editada: SOURABH BHATTACHARYA
el 22 de En. de 2022
0 votos
The first two are the top left (x,y) coordinates while the later ones are for max width and height respectively along the respectives axes.
Categorías
Más información sobre Images en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
