Get ROI (polygon) vertex information without moving it

2 views (last 30 days)
Dear All,
How to retrieve current vertex information only by passing the mouse over it? We know Matlab do this since enables us to delete that vertex with right-click. I need to get the vertex index (from the position list) just by passing over or with a single or double-click. The addlistener function only gets activated if the vertex or the ROI is moved, so does not work for my problem.
Example:
PosiList = [6 1;5 2;4 2;3 3;2 4;2 5;1 6;1 7;1 8;1 9;...
2 10;2 11;3 12;4 13;5 13;6 13;7 14;8 14;9 13];
handles.Poly = images.roi.Polygon(handles.sub1,'Position',PosiList,...
'LineWidth',1,'FaceAlpha',0.05,'MarkerSize',3,'Visible','on');
addlistener(handles.Poly,'AnyEvent',@allevents);
Any tip?
Thanks!
  1 Comment
Brunno Machado de Campos
Brunno Machado de Campos on 1 Sep 2022
Edited: Brunno Machado de Campos on 1 Sep 2022
How I solved:
addlistener(handles.Poly,'ROIClicked',@clickCallback);
and a nested function to get current mouse position comparing with all vertex position (ROI 'Position'):
function clickCallback(src,evt)
handles = guidata(hObject);
ClickPosi = get(gca,'CurrentPoint');
ClickPosi = round(C(1,1:2));
VertIdx = find(sum(ismember(src.Position,ClickPosi),2)>=length(ClickPosi));
end

Sign in to comment.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!