whscarp.m

来自「图像对齐(inage registration)工具箱」· M 代码 · 共 35 行

M
35
字号
function [HM,ANG,POSI]=whscarp(ST,fil)
% WHSCARP - computes what sign changes around points (one row of pixels)
%               [HM,ANG,POSI]=whscarp(ST,fil)
%
% ST: columns contain perimeter functions, last row=first
% fil: 1D filter to smooth the columns
% HM: number of sign changes in each column
% ANG: for two changes, distance (sharp angle) between them
% POSI: actual positions of sign changes
%
% Copyright Zitova B., Kautsky J., Peters G., Flusser J.
% UTIA, 1998

if nargin<2, fil=1; end

if length(fil) > 1
%    do the filtering here
end

[le,n]=size(ST);
le=le-1;             % no. of steps around "circle"
STsi = ST>=0 ;
STch = (STsi(1:le,:) ~= STsi(2:le+1,:));
HM = sum(STch);
ANG=zeros(1,n);
POSI=zeros(2,n);
for j=1:n
   if HM(j)==2
      tt=find(STch(:,j));
      ttt=tt(2)-tt(1);
      ANG(j)=min(ttt,le-ttt);
      POSI(:,j)=tt;
   end
end

⌨️ 快捷键说明

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