Extract position of all draw points
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali razi
am 29 Dez. 2021
Bearbeitet: Ali razi
am 30 Dez. 2021
Based on this question (https://www.mathworks.com/matlabcentral/answers/545177-draw-points-on-uiaxes-until-you-press-a-button-in-app-designer?s_tid=srchtitle), how can I get all the position of the pointhandles?
function StartButtonPushed(app, event)
imshow('peppers.png','Parent',app.ImageAxes);
userStopped = false;
pointhandles = gobjects();
while ~userStopped
a = drawpoint(app.ImageAxes);
if ~isvalid(a) || isempty(a.Position)
% End the loop
userStopped = true;
else
% store point object handle
pointhandles(end+1) = a;
end
end
disp(pointhandles)
end
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 29 Dez. 2021
Bearbeitet: Adam Danz
am 29 Dez. 2021
1. Add this to the end after the while-loop to get rid of the initial empty handle
pointhandles(1) = [];
2. Extract the position data from the pointhandles vector.
positions = cell2mat(get(pointhandles, 'position'))
positions will be an n*2 matrix of [x,y] coordinates for n points.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!