Hauptinhalt

Choose Approach to Annotate ROIs in Images

R2026b

A region of interest (ROI) is a portion of an image that you want to annotate, filter, or operate on. You can create ROI objects that represent circles, ellipses, polygons, lines, polylines, rectangles, and hand-drawn shapes. You can display ROI objects to annotate an image in a standalone display or in an app you build. Each ROI object stores information about its position, appearance, and behavior as object properties.

Polygon ROI that approximates the boundary of an object in an image.

Image Processing Toolbox™ provides three approaches for creating, displaying, and interacting with ROI objects on images. All options enable you to create and modify shapes on images, but they differ in performance, supported features, and intended use cases. The purpose of this page is to help you choose an approach for your use case.

Use When You NeedApproachSample ImageMore Information

  • The ability to add common shapes directly from the viewer toolbar without writing any code.

  • Fast, smooth interactions with large images, blocked images, or 3-D scenes when displaying tens or hundreds of ROIs.

  • Automatic measurement labels, such as the radius of a circle ROI, with the ability to customize units or text labels.

  • Access to the angle ROI, which is not supported for axes-based ROIs.

Use interactive viewer-based ROIs (since R2026a) to draw and edit shapes on images and volumes displayed using imageshow and volshow.

Create interactive ROIs by using the uidraw function.

Blue and red circle ROIs on an image of pears, showing a measurement label and a text label

Create Interactive Viewer-Based ROIs

  • Fast, smooth interactions with large images, blocked images, or 3-D scenes when displaying thousands to millions of ROIs.

  • Non-interactive overlay of detection results, segmentation boundaries, or vector fields on images or volumes.

  • Access to the arrow, plusses, ellipsoid, sphere, or cylinder ROIs, which are not supported for interactive or axes-based ROIs.

Use static viewer-based ROIs (since R2026b) to efficiently display many non-interactive shapes on images and volumes displayed using imageshow and volshow.

Create static ROIs by using the uiannotate function.

Blue rectangle ROIs overlaid on rice grains in a grayscale image

Create Static Viewer-Based ROIs

  • Maximum customization of ROI appearance, behavior, and callbacks. For example, you can customize the line width, marker size, or edge styles of an axes-based ROI object.

  • Integration with existing axes-based apps or imshow displays.

  • Access to the assisted freehand or crosshair ROIs, which are not supported for viewer-based ROIs.

Use axes-based ROIs to integrate with MATLAB® Graphics Objects and imshow displays.

Create axes-based ROIs using these functions:

Blue ellipse ROI and yellow and blue dashed ellipse ROI on an image of pears with visible vertex markers

Create Axes-Based ROIs

See Also

| | | | | | | | | |

Topics