필터 지우기
필터 지우기

Extract position of all draw points

조회 수: 3 (최근 30일)
Ali razi
Ali razi 2021년 12월 29일
편집: Ali razi 2021년 12월 30일
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

채택된 답변

Adam Danz
Adam Danz 2021년 12월 29일
편집: Adam Danz 2021년 12월 29일
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개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by