getbeforeafterpts.m

来自「asm工具箱」· M 代码 · 共 28 行

M
28
字号
%%%%%%%%%%%%%%%%%%%%%%%%%%
%(c) Ghassan Hamarneh 1999
%%%%%%%%%%%%%%%%%%%%%%%%%%

function [pt1,pt2]=GetBeforeAfterPts(index,ContoursEndingPoints);
%function [pt1,pt2]=GetBeforeAfterPts(index,ContoursEndingPoints);

if index==1
   pt1=ContoursEndingPoints(1);
   pt2=2;
elseif index==ContoursEndingPoints(1)
   pt1=ContoursEndingPoints(1)-1;
   pt2=1;
elseif index==ContoursEndingPoints(end)
   pt1=ContoursEndingPoints(end)-1;
   pt2=ContoursEndingPoints(end-1)+1;
elseif ismember(index-1,ContoursEndingPoints)
   tmp=find(index-1==ContoursEndingPoints);
   pt1=ContoursEndingPoints(tmp+1);
   pt2=index+1;
elseif ismember(index,ContoursEndingPoints)
   pt1=index-1;
   tmp=find(index==ContoursEndingPoints);
   pt2=ContoursEndingPoints(tmp-1)+1;
else
   pt1=index-1;
   pt2=index+1;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?