Measure Distance Between Pixels in Image Viewer App
The Image Viewer app enables you to measure the
Euclidean distance between two pixels using the Distance tool. The Distance tool displays the
line, the endpoints, and label with the distance measurement. The tool specifies the distance
in data units determined by the
properties, which is pixels, by default. You can save the endpoint locations and distance
Determine Distance Between Pixels Using Distance Tool
After you open an image in Image Viewer, open the Distance tool by clicking Distance tool button in the Image Viewer toolbar or selecting Measure Distance from the Tools menu.. For more information about opening an image in Image Viewer, see Open Image Viewer App.
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 first endpoint, hold down the mouse button, drag the cross hairs to the second endpoint, and release the button.
The figure shows a distance line with the line endpoints and distance measurement label.
You can also use a Distance tool with a figure, such as displayed using
imshow, by using the
Export Endpoint and Distance Data
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 Attributes distance 1x1 8 double point1 1x2 16 double point2 1x2 16 double
Customize the Appearance of the Distance Tool
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.
Toggle the distance tool label on and off using the Show Distance Label option.
Change the color used to display the Distance tool line using the Set color option.
Constrain movement of the tool to either horizontal or vertical using the Constrain drag option.
Delete the distance tool object using the Delete option.