Practical way to have multiple "drawrectangle" and work with them

8 ビュー (過去 30 日間)
William Thielicke
William Thielicke 2021 年 2 月 28 日
回答済み: William Thielicke 2021 年 2 月 28 日
I have an image displayed in an axes. The user should draw multiple rectangles using drawrectangle (command started via menu command in a GUI). When the user decides that there are enough recangles, he will start the tracking algorithm which will track the content of every rectangle he has drawn.
I am looking for the easiest way to work with these rectangles. Each rectangle has a Matlab-built-in context menu, that allows to delete or adjust the rectangle. So I need some sort of a dynamic list of rectangles that also react to the interactions with the context menu.
Here is the principle that generates a cell array of rectangles, but of course, it is not updated when the user interacts with the context menu. I am looking for a better way to generate and update this list of rectangles. Thank you for your help!!
% User adds a rectangle
if isempty(track_rectangles) %first time a rectangle is selected


William Thielicke
William Thielicke 2021 年 2 月 28 日
Ok, I found something in the help:
hfhs = findobj(gca, 'Type', 'images.roi.Rectangle')
Calling this just before starting the tracking will give you a list of all rectangles that have been drawn.

その他の回答 (0 件)


Help Center および File ExchangeLine Plots についてさらに検索




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by