Get ROI (polygon) vertex information without moving it

1 次查看(过去 30 天)
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 个评论
Brunno Machado de Campos
编辑:Brunno Machado de Campos 2022-9-1
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by