How to create a flexible rectangular box with a height and widht line at the center so that I can measure the height and width of the particular object in the image
Mostrar comentarios más antiguos
Hi All,
I have an image , right now I am using imline to calculate the height and width of the object in an image, I am wondering if have some tool in which we can create box around the object the perpendicular height and width line to measure. is there any tool or a way to create in matlab
Respuesta aceptada
Más respuestas (3)
I think the easiest compromise is to use impoly to draw an approximate rectangle around the tooth,
h=impoly(gca,'Closed',1);
Then, you can replace the polygon with its bounding rectangle using rectify(h) below. It relies on minboundrect from the File Exchange. You can tweak the vertices of the polygon interactively and re-apply rectify(h) until you are satisfied with the positioning.
function rectify(h)
pos=getPosition(h);
[rectx,recty] = minboundrect(pos(:,1),pos(:,2));
newpos=[rectx,recty];
setPosition(h,newpos(1:end-1,:));
end
1 comentario
Ankit Gupta
el 10 de Jun. de 2014
Matt J
el 6 de Jun. de 2014
0 votos
Just as there is imline, there is also imrect.
3 comentarios
Ankit Gupta
el 6 de Jun. de 2014
Matt J
el 6 de Jun. de 2014
But can I rotate the rectangle along the axis?
No, you cannot rotate an imrect.
also I want the Cross " +" inside the rectangle . Is it possible to do that?
I don't know what "the Cross" refers to.
Ankit Gupta
el 8 de Jun. de 2014
Matt J
el 8 de Jun. de 2014
0 votos
Another approach to consider is to use regionprops to compute the area and perimeter of the object. From the area and perimeter, you can solve for width and height.
Categorías
Más información sobre Display 2-D 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!
