I am using drawrectangle in an app so the user can interactively draw region of interest. It is not working consistently. Sometimes it works fine, but sometimes it draws the region with a offset in -x direction. I cannot figure out why it works sometimes and somstimes it doesn't. Here is a snippet of my code I am using to get the roi.
function [roi] = selectDataPoints(app,tab) delete(findall(app.([tab 'UIAxes']), 'Type', 'images.roi.Rectangle')) originalTitle = get(app.([tab 'UIAxes']).Title, {'String', 'Color'}); set(app.([tab 'UIAxes']).Title, 'String', 'Draw rectangle around region to clip.', 'Color', 'r') pan(app.([tab 'UIAxes']), 'off') %turn off panning so the interaction doesn't drag the data.
zoom(app.([tab 'UIAxes']),'off') roi = drawrectangle(app.([tab 'UIAxes']),'StripeColor','r','InteractionsAllowed','none'); % Return original title
set(app.([tab 'UIAxes']).Title, 'String', originalTitle{1}, 'Color', originalTitle{2}) end
Best Answer