MATLAB: How to label imrect while tracking

Image Processing Toolboxmoving lable for imrect

Dear all,
I am trying to make a tracking software using image processing toolbox only. I am using imrect for tracking a ROI. So I want to be able to add a label to that imrect blue box, let's say in the top of the box such that the label will be also moving with the rectangle generated from imrect.
Any idea how to do that?
Best, Meshooo

Best Answer

You can use plot(), line(), or rectangle() to draw/erase/move the rectangle. You can use text() to place a label near it.