Effacer les filtres
Effacer les filtres

Extract position of all draw points

6 vues (au cours des 30 derniers jours)
Ali razi
Ali razi le 29 Déc 2021
Modifié(e) : Ali razi le 30 Déc 2021
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

Réponse acceptée

Adam Danz
Adam Danz le 29 Déc 2021
Modifié(e) : Adam Danz le 29 Déc 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.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by