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

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

Image Analyst
Image Analyst el 8 de Jun. de 2014
Editada: Image Analyst el 8 de Jun. de 2014
You can use regionprops() to get the bounding box (length and width parallel to the image edges), convex hull, and major and minor axis lengths (fitting the blob(s) to an ellipse). See my Image Segmentation tutorial for a demo: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862.
If you want the farthest two points in an image and the cross sectional width at the mod point, then let me know, because that's not built in.

3 comentarios

Thank you image analyst, I will check this demo. right now what I am doing is I have an image of teeth and I am using imline to get the height and width of the that teeth by drawing the vertical and horizontal line( like the line of symmetry)and since I am drawing the 2 lines manually its difficult to get the perfect 90 deg angel between those 2 lines aligning with teeth plane. I was hoping to find some tool which I can align and rotate along the axis while measuring the height and width of that object.
Hi Image analyst , is there any way to constraint the the imline to be always perpendicular to the other imline drawn on the same object. for ex. I draw a first line using "imline" now I want to draw second line across the first line to be perpendicular to it. if there is a way to force the second imline to be perpendicular to the first line it will solve my problem some extent.
Anikit: Please run my attached spatial calibration demo.

Iniciar sesión para comentar.

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
Just as there is imline, there is also imrect.

3 comentarios

But can I rotate the rectangle along the axis? also I want the Cross " +" inside the rectangle . Is it possible to do that? as i want to measure the height and width and i want both lines to be perpendicular.
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.
Something like a rectangle (with lines of symmetry) which I can rotate along the axis to allign with the object. or is there a way to overlay an image (rectangle image) on a object.

Iniciar sesión para comentar.

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.

Preguntada:

el 6 de Jun. de 2014

Comentada:

el 10 de Jun. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by