Updating Positions of ROI

5 Ansichten (letzte 30 Tage)
Omer Akatekin
Omer Akatekin am 20 Mär. 2021
Kommentiert: Omer Akatekin am 20 Mär. 2021
Hi,
I would like to let user to draw line on image and after drawing is completed (resizing and moving line)
i would like to process position of line to determine length of line.
I = imread('File Path.jpeg');
imshow(I);
roi = drawline;
x = roi.Position;
listener(roi,'ROIMoved',@allevents);
function allevents(~,evt)
evname = evt.EventName;
if evname == 'ROIMoved'
a =evt.CurrentPosition
end
end
However when drawn line position is changed i could not get the evt.Current Position value into workspace .
  1 Kommentar
Omer Akatekin
Omer Akatekin am 20 Mär. 2021
Well i found another solution:
Is it possible change ROIClicked to PressEnter ?
I = imread('*.jpeg');
imshow(I);
h = drawline;
pos = customWait(h);
function pos = customWait(hROI)
% Listen for mouse clicks on the ROI
l = addlistener(hROI,'ROIClicked',@clickCallback);
% Block program execution
uiwait;
% Remove listener
delete(l);
% Return the current position
pos = hROI.Position;
end
function clickCallback(~,evt)
if strcmp(evt.SelectionType,'double')
uiresume;
end
end

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by