Skip to content
Snippets Groups Projects
Commit 5ecda002 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

GUI: Added simple function for efficiently collect point coordinates by clicking in the image

parent 15c5dfd1
No related branches found
No related tags found
No related merge requests found
function points = gtGuiCollectPointsFromImage(map)
f = figure();
ax = axes('parent', f);
map = (map - min(map(:))) ./ (max(map(:)) - min(map(:)));
im = imagesc(map, 'parent', ax);
cm = uicontextmenu('Parent', f, 'Callback', @(src, evt)save_clicked_point());
set(im, 'UIContextMenu', cm);
uimenu(cm, 'Label', 'Add point..', 'Callback', @(src, evt)add_current_point());
uimenu(cm, 'Label', 'Exit', 'Callback', @(src, evt)get_finally_out());
point = zeros(1, 2);
points = zeros(0, 2);
get_out = false;
while(~get_out)
pause(0.001);
end
close(f);
function save_clicked_point()
point = get(ax, 'CurrentPoint');
point = round(point(1, 1:2));
end
function add_current_point()
points(end+1, :) = point;
end
function get_finally_out()
get_out = true;
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment