| Image Processing Toolbox™ | ![]() |
| On this page… |
|---|
Display an image in the Image Tool.
imtool('moon.tif') Click the Distance tool
button
in the Image Tool toolbar or select Measure
Distance from the Tools menu.
The Distance tool allows you to measure distance with a click-and-drag
approach. When you move the pointer over the image, the pointer changes
to cross hairs
. Position the cross hairs at the beginning
of the region you wish to measure, hold down the mouse button, drag
the cross hairs to the end of the region, and release the button.
The Distance tool displays the Euclidean distance between the two endpoints of the line in a label superimposed over the line. The tool specifies the distance in data units determined by the XData and YData properties, which is pixels, by default.

An alternative to using the Distance tool in Image Tool is to open a figure window using imshow and then call imdistline. The Distance tool appears as a horizontal line displayed over the image. You can reposition the line or grab either of its endpoints to resize the tool.
To save the endpoint locations and distance information, right-click the Distance tool and choose the Export to Workspace option from the context menu. The Distance tool opens the Export to Workspace dialog box. You can use this dialog box to specify the names of the variables used to store this information.

After you click OK, the Distance tool creates the variables in the workspace, as in the following example.
whos Name Size Bytes Class distance 1x1 8 double array moon 537x358 192246 uint8 array point1 1x2 16 double array point2 1x2 16 double array
Using the Distance tool context menu, you can customize many aspects of the Distance tool appearance and behavior. Position the pointer over the line and right-click to access these context menu options.
Toggling the distance tool label on and off using the Show Distance Label option.
Changing the color used to display the Distance tool line using the Set color option.
Constraining movement of the tool to either horizontal or vertical using the Constrain drag option.
Deleting the distance tool object using the Delete option.
Right-click the Distance tool to access this context menu.
![]() | Getting Information about the Pixels in an Image | Getting Information About an Image Using the Image Information Tool | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |