Extract position of all draw points

15 visualizaciones (últimos 30 días)
Ali razi
Ali razi el 29 de Dic. de 2021
Editada: Ali razi el 30 de Dic. de 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

Respuesta aceptada

Adam Danz
Adam Danz el 29 de Dic. de 2021
Editada: Adam Danz el 29 de Dic. de 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.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by