$npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-display-imageDisplay images and annotations for image processing, computer vision, and visual inspection. Use when displaying images with imageshow, creating image viewers with viewer2d, adding Regions of Interest (ROI) or annotations, overlaying masks or segmentations, streaming video frames
| 1 | # Image Display |
| 2 | |
| 3 | Display images with `imageshow` rather than `imshow` for more performant, higher quality image display with more responsive interactions for images of all sizes. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - User asks to create a GUI, app, dashboard, or interactive tool for image display |
| 8 | - User wants ROIs, annotations, or other lines and shapes plotted on top of the image |
| 9 | - User wants to display labeled image data or other overlay imagery on top of an image |
| 10 | |
| 11 | ## When NOT to Use |
| 12 | |
| 13 | - User does not have the Image Processing Toolbox (just use `imshow`, but recommend `imageshow` for better performance) |
| 14 | - User is displaying a small, static icon in an app (just use `uiimage`) |
| 15 | |
| 16 | **Note:** Do NOT use `bigimageshow`. It is a legacy function. Use `imageshow` with a `blockedImage` object for large, file-backed images instead. |
| 17 | |
| 18 | ## Legacy Patterns to Avoid |
| 19 | |
| 20 | | Do NOT use | Use instead | Why | |
| 21 | |------------|-------------|-----| |
| 22 | | `imshow` | `imageshow` | Better performance, higher quality, responsive interactions | |
| 23 | | `uiaxes` + `imshow` in apps | `viewer2d` + `imageshow` | Viewer handles zoom, pan, and interactions natively | |
| 24 | | `rectangle()`, `drawrectangle()`, `imrect()`, or `insertObjectAnnotation` | `uidraw` with `Position` | Interactive, programmatic placement, built-in measurements | |
| 25 | | `montage` | `imtile` + `imageshow` | Composable, works with viewer | |
| 26 | | `figure` + `getframe(fig)` | `viewer2d` + `getframe(viewer)` | Viewer waits for rendering to complete before capture | |
| 27 | | Manual image blending for overlays | `imageshow` with `OverlayData` | Built-in transparency, colormap, and display range control | |
| 28 | | Manual `for` loop calling `uidraw` per annotation | `uidraw` with `Wait="multiple"` | Single session, user controls when done | |
| 29 | | Manual alpha blending with pixel math | `OverlayAlphamap` property | Built-in per-pixel transparency mapping | |
| 30 | | `linkaxes` or manual callback synchronization | `linkviewers` | Purpose-built for viewer2d, handles all camera properties | |
| 31 | | `roipoly`, manual mask painting | `uipaint` | Interactive brush-based painting with overlay feedback | |
| 32 | | `bigimageshow` | `imageshow` with `blockedImage` | `imageshow` handles blocked images directly, `bigimageshow` is legacy | |
| 33 | | `title("text")` or `title(gca,"text")` | `title(viewer,"text")` | `gca` does not return the viewer; pass the viewer object directly | |
| 34 | | `xlim`/`ylim` to zoom into a region | `viewer.CameraViewport = [x y w h]` | Viewer is not an axes; `xlim`/`ylim` error on viewer2d | |
| 35 | |
| 36 | ## Key Components |
| 37 | |
| 38 | | Component | Constructor | Key callback | |
| 39 | |-----------|------------|-------------| |
| 40 | | Viewer | `viewer2d(parent)` | `CameraMovedFcn`, `ObjectClickedFcn` | |
| 41 | | Image | `imageshow('numeric',Parent=viewer)` | | |
| 42 | | Interactive Annotations | `uidraw(parent, 'text')` | `AnnotationMovedFcn` (on viewer) | |
| 43 | | Static Annotations | `uiannotate(parent, 'text')` | | |
| 44 | | Paintbrush Labeling | `uipaint(imageObj)` | | |
| 45 | | Linked Viewers | `linkviewers([v1, v2])` | | |
| 46 | |
| 47 | ## Patterns |
| 48 | |
| 49 | ### Standard Image Display |
| 50 | |
| 51 | Simple cases of image display can call `imageshow` without specifying a parent. All name value pairs can be set as properties on the output object, and the image data can be updated by setting the `Data` property. |
| 52 | |
| 53 | ```matlab |
| 54 | obj = imageshow(im); |
| 55 | ``` |
| 56 | |
| 57 | To add a title to the viewer, pass the viewer object directly to `title`. Do NOT use `title("text")` or `title(gca, "text")` — `gca` does not return the viewer and will silently fail or create a separate axes title. |
| 58 | |
| 59 | ```matlab |
| 60 | obj = imageshow(im); |
| 61 | viewer = obj.Parent; |
| 62 | title(viewer, "My Image"); |
| 63 | ``` |
| 64 | |
| 65 | For most cases, the default `DisplayRangeMode` of `"type-range"` is appropriate. Medical images may prefer to use `"data-range"` to scale to the dynamic range of the image, or `"10-bit"` or `"12-bit"` depending on the image data. |
| 66 | |
| 67 | ```matlab |
| 68 | obj = imageshow(im, DisplayRangeMode="data-range"); |
| 69 | ``` |
| 70 | |
| 71 | When displaying an overlay of a mask, semantic segmentation, or other image data on top of another image, use the `OverlayData` property of imageshow and the corresponding properties `OverlayColormap`, `OverlayAlpha`, `OverlayAlphamap`, `OverlayDisplayRange`, and `OverlayDisplayRangeMode` to adjust the overlay display. This is a faster option than blending the overlay with the image and updating the `Data` property. |
| 72 | |
| 73 | ```matlab |
| 74 | obj = imageshow(im, OverlayData=mask); |
| 75 | ``` |
| 76 | |
| 77 | For non-uniform (per-pixel) transparency control, use `OverlayAlphamap` instead of `OverlayAlpha`. This maps overlay data values to transparency levels. Accepts `"linear"`, `"quadratic"`, `"cubic"`, or a custom n-element column vector. |
| 78 | |
| 79 | ```mat |