uipaint
Description
enables
an interactive paintbrush tool within the specified image viewer, where
BW = uipaint(Im)Im is an Image object returned by the imageshow
function. The image viewer enters an interactive painting mode, in which you can draw and
erase overlay pixels and accept the updated overlay. The function returns the pixels you
draw as a binary mask and updates the OverlayData property of
Im.
specifies additional options using one or more name-value arguments. For example,
BW = uipaint(Im,Name=Value)OverlayValue=3 sets the OverlayData property value
of the pixels you draw to 3.
Examples
Input Arguments
Name-Value Arguments
Output Arguments
Tips
The MATLAB® command line is blocked while the paintbrush tool is enabled. To turn off the paintbrush, accept the updated overlay in the viewer toolbar.
A pixel is
truein the output mask if the paintbrush tool paints the center of the pixel.In addition to specifying the
BrushSizename-value argument, you can change the brush size while painting by clicking inside the viewer and holding Shift while scrolling the mouse wheel.Depending on your use case, you can get the labels you paint using the
uipaintfunction in these ways.Screenshot — To capture and view the image overlay outside MATLAB, right-click the image and select Copy screenshot to clipboard or Save screenshot to file.
Binary mask — To access the pixels drawn during only one paintbrush interaction, get the corresponding output mask
BW.Label image — To access the complete overlay image for an
Imageobject, access theOverlayDataproperty of that object using dot notation. Each overlay color represents a differentOverlayDatavalue.
Version History
Introduced in R2026a








