How to Move Multiple ROI's at the same time?
Show older comments
Hi Everyone :)
I have 4 ROI's on an image, and I want to move the left two, and then the right two collectively in the figure (So grouping two ROIs to move simultaneously). Is there a way to do this?
Thank You!!
4 Comments
Guillaume
on 26 Jul 2018
What does "move a roi in a figure" actually mean?
This will create a figure:
figure;
What is supposed to move, and where is it supposed to move in there?
Harry Andrews
on 26 Jul 2018
Guillaume
on 26 Jul 2018
How are these roi created in your image?
Harry Andrews
on 26 Jul 2018
Accepted Answer
More Answers (1)
Tim Jackman
on 21 Sep 2018
This should be doable with drawpolygon, the new ROI released with 18b. Here is an example that allows you draw two polygons, and then wire them up such that any translation applied to one ROI is also applied to the other.
figure;
hAx = axes;
% Construct two Polygons
hROI1 = drawpolygon(hAx,'Tag','ROI1','InteractionsAllowed','translate');
hROI2 = drawpolygon(hAx,'Tag','ROI2','Color',[1 0 0],'InteractionsAllowed','translate');
% Add listener to update the other ROI when moved
addlistener(hROI1,'MovingROI',@movingCallback);
addlistener(hROI2,'MovingROI',@movingCallback);
function movingCallback(~,evt)
% Use findobj to identify which ROI moved
hROI1 = findobj(gcf,'Tag','ROI1');
hROI2 = findobj(gcf,'Tag','ROI2');
delta = evt.CurrentPosition(1,:) - evt.PreviousPosition(1,:);
% If we move one ROI, set the position of the other
if evt.Source == hROI1
hROI2.Position = hROI2.Position + delta;
else
hROI1.Position = hROI1.Position + delta;
end
end
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!