Set color used to draw ROI object
setColor is not recommended. With the new ROIs, set the value of
Color property instead. For more information, see Compatibility Considerations.
Display an image. Draw a polygon on the image, specifying the location of five vertices.
imshow('gantrycrane.png') h = impoly(gca,[188,30; 189,142; 93,141; 13,41; 14,29]);
Set the color of the polygon to yellow.
color— RGB color value
RGB color value, specified as a 3-element numeric vector, or the long or
short name of a predefined color, such as
ColorSpec for a list of
setColoris not recommended
Not recommended starting in R2018b
Starting in R2018b, a new set of ROI objects replaces the existing set of ROI objects. The new objects provide more functional capabilities, such as face color transparency. The new classes also support events that you can use to respond to changes in your ROI such as moving or being clicked. Although there are no plans to remove the old ROI objects at this time, switch to the new ROIs to take advantage of the additional capabilities and flexibility. For more information on creating ROIs using the new ROI functions, see ROI Creation Overview.
To set the color of the new ROIs, set the value of the
Update all instances of
|Discouraged Usage||Recommended Replacement|
This example creates an ROI and uses
imshow('cameraman.tif'); h = imrect(gca,[10 10 100 100]); setColor(h,'yellow');
Replace the ROI with the equivalent new ROI object.
Then, delete the call to
imshow('cameraman.tif'); h = drawrectangle(gca,'Position',[10 10 100 100]); h.Color = 'yellow'