Get ROI (polygon) vertex information without moving it

조회 수: 1 (최근 30일)
Brunno Machado de Campos
Brunno Machado de Campos 2022년 9월 1일
편집: Brunno Machado de Campos 2022년 9월 1일
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일
편집: 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개)

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by