Main Content

Measure Distances and Areas Using Image Viewer App

The Image Viewer app enables you to measure the Euclidean distance between two pixels, or the area within a polygon. The app displays the line or polygon region of interest (ROI) and measurement labels, in units of pixels. You can create multiple measurements and export measurements to the workspace.

Determine Distance Between Pixels

  1. Load an image into Image Viewer. For more information about opening images in the app, see Open Image Viewer App.

  2. On the Viewer tab of the app toolstrip, select Measure Distance.

  3. To draw the measurement line, move the pointer to the image, so the pointer changes to a crosshairs . Position the crosshairs at the first endpoint, left-click, and then drag the cross hairs to the second endpoint and release the mouse button.

  4. You can reposition individual endpoints or move the whole line by dragging the ends or middle portion of the line, respectively.

This figure shows a distance line with the line endpoints and distance measurement label. The app bases distance measurements on the image coordinates rather than the pixel grid, such that the value includes decimals and is not rounded to the nearest whole pixel.

Grayscale image of the moon, showing a distance line with length 88.3647 pixels

Note

You can also measure distances in a figure created by imshow by using the imdistline function.

Determine Area of Polygon

  1. Load an image into Image Viewer. For more information about opening images in the app, see Open Image Viewer App.

  2. On the Viewer tab of the app toolstrip, select Measure Area.

  3. To draw a polygon around the region of interest, move the pointer to the image, so the pointer changes to a crosshairs . Left-click to add a vertex to the polygon. To finish the polygon, double-click.

  4. You can reposition individual vertices or translate the whole polygon by dragging a vertex or the inside of the polygon, respectively. To delete a single vertex, right-click the vertex and select Delete Vertex. To add a vertex, right-click a line segment and select Add Vertex.

This figure shows a polygon with the area measurement label in pixels. The app bases area measurements on the image coordinates rather than the pixel grid, such that the value includes decimals and is not rounded to include or exclude whole pixels.

Grayscale image of the moon, showing a polygon with an area of 119.7228 pixels

Hide or Delete Measurements

You can control whether the main display pane shows distance and area measurements.

  • To temporarily hide all measurements, on the Viewer tab of the app toolstrip, clear Show All. Select Show All again to show the measurements.

  • To permanently delete all measurements, from the app toolstrip, select Delete All.

Export Distance and Area Measurements

On the Viewer tab of the app toolstrip, select Export > Export Measurements. Use the Export to Workspace dialog box to select the measurements to export and to specify the names for each corresponding workspace variable.

Export to Workspace dialog box

When you click OK, the app creates the variables in the workspace.

See Also

|

Related Topics