How to Move Multiple ROI's at the same time?
이전 댓글 표시
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
Guillaume
2018년 7월 26일
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
2018년 7월 26일
Guillaume
2018년 7월 26일
How are these roi created in your image?
Harry Andrews
2018년 7월 26일
채택된 답변
추가 답변 (1개)
Tim Jackman
2018년 9월 21일
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
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
