基于角点的图像配准
基于角点的图像配准 课程设计
班级:
专业:
学号:
姓名:
021151 智能科学与技术 02115004
基于角点的图像配准
图像配准现在已成为数字图像处理的研究热点,方法繁多,站在时代的前沿。图像配准多采用基于图像特征点的方法,这种方法易于用计算机处理并且容易实现人机交互,其重点在于如何提取图像上的有效特征点。
对图像拼接技术的目的、意义、国内外研究现状、发展方向以及本课题研究的目的和意义进行了阐述,着重介绍了图像拼接过程的核心技术——图像配准。阐明了现有配准方法的工作原理,并对常用的各种经典算法的优点和不足进行了比较总结。
角点定义
图像匹配的算子,主要是用来提取两幅配准图像中的角点。角点,又称为兴趣点,是像素点在其邻域内的各个方向上灰度变化量足够大的点,且大于阈值的点。它是一种重要的图像特征点,包含了图像中丰富的二维结构信息,广泛应用于各种图像处理技术中。角点最大的优点是:它所代表的局部结构关系信息不会因为视角的不同而改变,这在三维物体识别上很有用。此外,角点特征也常用在汉字识别,染色体识别等应用系统中。
常用角点检测的算法
Harris 算子
Harris 算子是Harris 和Stephens 提出的一种基于信号的角点特征提取的算子。其处理过程表示如下: [7]
2⎡g x M =G (~s ) ⊗⎢⎢g x g y ⎣g x g y ⎤(2-1) 2⎥g y ⎦⎥
R =det(M ) -k *tr 2(M ) k =0. 04~0. 06(2-2)
s ) 为高斯模板,det 式中:g x 为x 方向上的梯度,g y 为y 方向上的梯度,G (~
为矩阵的行列式,tr 为矩阵的迹,k 为常数,R 表示图中相应像素点的兴趣值。
小波变换算子
小波变换算子可以非常有效地用于信号的多分辨率局部分析,它已经被成[8]
功的用于许多图像分析领域。对于图像配准来说,由于两幅图像中共同特征往往是大而强的边缘信息,根据小波变换能够反映图像的阶跃型边缘突变点的性质,可以利用小波变换提取用于图像配准的特征点。
假设图像P 具有M ⨯M 个像素。在J =log 2M +1个尺度上对P 进行分解,即尺度s =2i , 1≤j ≤J 。选择适当的二维平滑函数θ(x , y ) ,定义小波为:
ψ1(x , y ) =∂θ(x , y ) (2-3) ∂x
ψ2(x , y ) =∂θ(x , y ) (2-4) ∂y
构造出离散滤波器,在尺度2j 上,采用二维离散小波变换的快速算法计算每个点(m , n ) 的离散二进小波变换W 21j d f (m , n ) ,W 22j d f (m , n ) 。点(m , n ) 的模值为:
M 2d j f (m , n ) =1d
2j f (m , n ) +22d
2j f (m , n ) (2-5) 2
相角为:
W j f (m , n ) (2-6) A 2j f (m , n ) =2
1d W 2j f (m , n ) d 2d
然而,模极大值点就是该点的模大于在相角方向上的两个相邻位置上模值的点。当模极大值点大于所设定的门限值时,则该点被认为是特征点。 Moravec 算子
Moravec 算子是Moravec 提出的利用灰度方差提取点特征的算子。其提取[9]
点特征的步骤为:
(1)计算各像元的兴趣值IV (Interest Value)。在以像素(m , n ) 为中心的w ⨯w 的图像窗口中,相邻4个方向像素灰度差的平方和为:
V 1=
i =-k ∑(g k -1m +i , n -g m +i +1, n ) 2(2-7)
V 2=
i =-k ∑(g k -1m +i , n +i -g m +i +1, n +i +1) 2(2-8)
V 3=
i =-k
k -1∑(g k -1m , n +i -g m , n +i +1) 2(2-9)
V 4=
i =-k ∑(g m +i , n -i -g m +i +1, n -i -1) 2(2-10)
式中:k =int(w /2) 。取其中最小者作为该像素的兴趣值,即:
IV m , n =min {V 1, V 2, V 3, V 4}(2-11)
(2)给定一经验阈值,将兴趣值大于该阈值的点作为候选点,阈值的选择应以候选点中包括所需要的特征点,而又不含过多的非特征点为原则。
(3)选取候选点中的极值点作为特征点,在一定大小的窗口内(可不同于兴趣值计算窗口),将候选点中兴趣值不是最大者去掉,仅留下一个兴趣值最大者,该像素即为一个特征点。
Forstner 算子
Forstner 算子是通过计算各像素的Robert’s梯度和以像素(m , n ) 为中心的一[10]
个窗口灰度协方差矩阵,在图像中寻找具有尽可能小而接近圆的误差椭圆的点作为特征点。其步骤为:
(1)计算各像素的Robert’s梯度
g u =∂g =g i +1, j +1-g i , j (2-12) ∂u
∂g g v ==g i , j +1-g i +1, j (2-13) ∂v
(2)计算r ⨯r 窗口中灰度的协方差矩阵
2⎡g ∑u Q =N -1⎢⎢⎣∑g v g u ∑g g ∑g u
2
v v ⎤⎥(2-14) ⎥⎦
式中:k =int(r /2)
∑g 2
u m +k +1n +k -1=
i =m -k j =n -k ∑∑(g
∑i +1, j +1-g i , j ) 2(2-15) ∑g =2
v m +k +1n +k -1
i =m -k j =n -k 2(g -g ) ∑i , j +1i +1, j (2-16)
∑g
(3)计算兴趣值q 和w m +k +1n +k -1u g v =i =m -k j =n -k ∑∑(g i +1, j +1-g i , j )(g i , j +1-g j +1, i ) (2-17)
q =4DetN 1DetN (2-18) , w ==2trQ trN (trN )
式中:DetN 代表矩阵N 的行列式;trN 代表矩阵N 的迹。
(4)确定待选点
如果兴趣值大于给定的阈值,则该像元为待选点,阈值为经验值,可参考下列值:T q =0. 5~0. 75
⎧f T w =⎨⎩cw c (f =0. 5~1. 5) (c =5) (2-19) 式中:为权平均值;w c 为本权的中值。当q >T q ,且w >T w 时,该像素为待选点。
(5)选取极值点
以权值w 为依据,选择极值点,即在一个适当窗口中选择w 最大的待选点,而去掉其余的点。
常用角点检测算法比较
Harris 角点检测算法是基于图像的灰度自相关函数的一种算法,该算法直接从原始图像中检测特征点,能够在图像发生灰度变化、旋转和干扰噪声等情况下检测兴趣点。相对于 Moravec 算法,在抗噪能力有了很大提高,而且兼顾了效率和精度两方面的要求,误检测率低。提取的角点均匀合理,可以定量提取特征点,计算量小,易于编程。
基于小波变换的特征点提取算法在实际应用中,可以满足图像配准的要求,而且适用性也比较强,但是由于它的计算量比较大,不利于图像的快速配准,用MATLAB 软件对其编程,运行时间需要的较多。
Moravec 角点检测算法是一种比较传统的提取兴趣点的算法,由于该算法是通过计算水平、垂直、对角线、反对角线四个方向上灰度方差检测角点,该算子各项异性。具有思路简单,计算过程易于实现,判断条件少的优点,但其定位准确度不高,抗噪能力较低。
Forstner 算子与Moravec 算子有大多数的方面相似,都是传统的点特征的提取算法,它们对各个像素邻域进行一定的梯度或差分运算,选择其极值点(极大
或者极小)或超过给定阈值的点作为特征点。它们提取的特征点较强的依赖于局部灰度信息,其适应性较差而且计算量较大,因此,它们逐步被基于小波变换算子所代替。
运行结果:
附录:
%基于角点的图像配准
clc;
close all
clear all;
fprintf('%s\n','图像配准算法... ...'); % 读入基准图像
%BaseImage=imread('D:\Image\Frame3200.bmp'); % 读入实时图像
%TempImage=imread('D:\Image\Frame3240.bmp'); TempImage=imread('D:\Image\bb.bmp'); TempImage=rgb2gray(TempImage);
TempImage = wiener2(TempImage,[4,4]);
BaseImage=imread('D:\Image\ZOpt-1172.bmp');
BaseImage=rgb2gray(BaseImage);
BaseImage= wiener2(BaseImage,[4,4]);
%BaseImage = adapthisteq(BaseImage,'Distribution','rayleigh');
% % 读入基准图像
% BaseImage=imread('D:\MATLAB701\work\Test_Images_Data19\pic_3.bmp'); % % 读入实时图像
%
TempImage=imread('D:\MATLAB701\work\Test_Images_Data19\pic_18.bmp');
figure(1);
imshow(BaseImage);
title('基准图像');
figure(2);
imshow(TempImage);
title('实时图像');
% 获取基准图像的大小
[BaseHeight,BaseWidth]=size(BaseImage);
% 获取实时图像的大小
[TempHeight,TempWidth]=size(TempImage);
% 角点邻域匹配窗口尺度因子
Step_Corner=6;
% 图像外围截取尺度
Step_Image=8;
fprintf('%s\n','Harris兴趣点特征提取... ...');
% Harris角点提取
tt_base=0.01;
tt_temp=0.1;
[posc_base,
posr_base,cnt_base]=harris_corner(BaseImage((Step_Image+1):(BaseHeight-Step_Image),(Step_Image+1):(BaseWidth-Step_Image)),tt_base);
[posc_temp,
posr_temp,cnt_temp]=harris_corner(TempImage((Step_Image+1):(TempHeight-Step_Image),(Step_Image+1):(TempWidth-Step_Image)),tt_temp);
% 还原角点真实位置
for i=1:cnt_base
posc_base(i,1)=posc_base(i,1)+Step_Image;
posr_base(i,1)=posr_base(i,1)+Step_Image;
end
for i=1:cnt_temp
posc_temp(i,1)=posc_temp(i,1)+Step_Image;
posr_temp(i,1)=posr_temp(i,1)+Step_Image;
end
% 显示出角点提取结果
figure(3);
imshow(BaseImage);
hold on;
plot(posr_base,posc_base,'r+');
hold off;
figure(4);
imshow(TempImage);
hold on;
plot(posr_temp,posc_temp,'g+');
hold off;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 以下将利用交叉相关匹配进行基准图像和实时图像中同名角点的映射
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('%s\n','兴趣点特征交叉相关匹配... ...');
% 同名角点数目初始化
NumPoints_match=0;
% Thresh_Cor=0.6;
% 遍历实时图像中所有的角点
for i=1:cnt_temp
% 取定一角点
Index_c=posr_temp(i,1);
Index_r=posc_temp(i,1);
% 在实时图像中提取以取定角点为中心的一定大小的图像区域
AreaInTemp=TempImage(Index_r-Step_Corner:Index_r+Step_Corner,Index_c-Step_Corner:Index_c+Step_Corner);
[AreaInTempCir,MaskT,CntT]=Circle_Area(AreaInTemp,Step_Corner);
% 将提取的图像区域与基准图像中个角点邻域进行匹配,以相关匹配测度最大值所对应的角点为与实时图像中取定的角点匹配的候选角点
%
[match_r,match_c]=AreaMatch(AreaInTemp,BaseImage,posr_base,posc_base,cnt_base,Step_Corner);
[match_r,match_c,corBT]=Area_Matched(BaseImage,AreaInTempCir,posr_base,posc_base,cnt_base,MaskT,CntT,Step_Corner);
% 在基准图像中,以上一步中得到的候选匹配角点为中心提取一定大小的图像区域
AreaInBase=BaseImage(match_r-Step_Corner:match_r+Step_Corner,match_c-Step_Corner:match_c+Step_Corner);
[AreaInBaseCir,MaskB,CntB]=Circle_Area(AreaInBase,Step_Corner);
% 将提取的基准图像区域与实时图像中各个角点对应的邻域进行相关匹配,取匹配值最大所对应的角点
%
[match_rr,match_cc]=AreaMatch(AreaInBase,TempImage,posr_temp,posc_temp,cnt_temp,Step_Corner);
[match_rr,match_cc,corTB]=Area_Matched(TempImage,AreaInBaseCir,posr_temp,posc_temp,cnt_temp,MaskB,CntB,Step_Corner);
% 如果匹配得到的实时图像中的角点位置与开始所取定的角点位置重合或者比较接近,这认为找到一对同名角点
if(abs(match_rr-Index_r)0.8)&&(corTB>0.8))
% 同名角点数目增1
NumPoints_match=NumPoints_match+1;
CorMtri(NumPoints_match,1)=corBT;
CorMtri(NumPoints_match,2)=corTB;
% 同名角点对中实时图像中角点的位置坐标
MatrixPoints_matched(NumPoints_match,1)=Index_r;
MatrixPoints_matched(NumPoints_match,2)=Index_c;
% 同名角点对中基准图像中角点的位置坐标
MatrixPoints_matched(NumPoints_match,3)=match_r;
MatrixPoints_matched(NumPoints_match,4)=match_c;
% 同名角点之间的坐标差值
MatrixPoints_matched(NumPoints_match,5)=Index_r-match_r;
MatrixPoints_matched(NumPoints_match,6)=Index_c-match_c;
%%%
%figure;
%imshow(TempImage);
%hold on
%plot(Index_c,Index_r,'y*');
%figure;
%imshow(BaseImage);
%hold on
%plot(match_c,match_r,'w*');
end
end
% 显示同名角点的坐标变化、坐标差值及其直方图统计
% figure(5);
% plot(MatrixPoints_matched(:,1),'r');
% hold on;
% plot(MatrixPoints_matched(:,3),'g');
% hold on;
% plot(MatrixPoints_matched(:,5),'b');
% title('同名角点竖直方向的坐标差值');
% hold off;
% hist_r=hist(MatrixPoints_matched(:,5));
% figure(6);
% hist(MatrixPoints_matched(:,5));
% title('同名角点竖直方向的坐标差值统计直方图');
% figure(7);
% plot(MatrixPoints_matched(:,2),'r');
% hold on;
% plot(MatrixPoints_matched(:,4),'g');
% hold on;
% plot(MatrixPoints_matched(:,6),'b');
% title('同名角点水平方向的坐标差值');
% hold off;
% hist_c=hist(MatrixPoints_matched(:,6));
% figure(8);
% hist(MatrixPoints_matched(:,6));
% title('同名角点水平方向的坐标差值统计直方图');
fprintf('%s\n','同名兴趣点间的坐标差值统计分析... ...');
% 对交叉匹配得到的同名角点间的坐标差值进行统计,得到差值标准差和均值
[avg_r,delta_r]=MeanStD(MatrixPoints_matched(:,5),NumPoints_match);
[avg_c,delta_c]=MeanStD(MatrixPoints_matched(:,6),NumPoints_match);
% 对同名角点间的坐标差值进行聚类累积(类似直方图分布分析)
[Num_r,Num_cumu_r,Hist_row]=HistData(NumPoints_match,MatrixPoints_matched(:,5));
[Num_c,Num_cumu_c,Hist_col]=HistData(NumPoints_match,MatrixPoints_matched(:,6));
% 利用累积峰值处对应的坐标差值对实时图像相对于基准图像的坐标偏移量进行预估
Delta_H=Hist_row(1,find(Num_cumu_r==max(Num_cumu_r)));
Delta_H=Delta_H(1,1);
Delta_W=Hist_col(1,find(Num_cumu_c==max(Num_cumu_c)));
Delta_W=Delta_W(1,1);
% 利用坐标差值分布标准差(离散度)和坐标偏移估计值对交叉匹配得到
的同名兴趣点进行筛选
Num_Accept=0;
for i=1:NumPoints_match
%if((abs(MatrixPoints_matched(i,5)-Delta_H)
Num_Accept=Num_Accept+1;
Accept_TR(Num_Accept,1)=MatrixPoints_matched(i,1);
Accept_TC(Num_Accept,1)=MatrixPoints_matched(i,2);
Accept_BR(Num_Accept,1)=MatrixPoints_matched(i,3);
Accept_BC(Num_Accept,1)=MatrixPoints_matched(i,4);
%figure;
%imshow(TempImage);
%hold on
%plot(Accept_TC(Num_Accept,1),Accept_TR(Num_Accept,1),'co'); %figure;
%imshow(BaseImage);
%hold on
%plot(Accept_BC(Num_Accept,1),Accept_BR(Num_Accept,1),'mo'); %end
end
%
[a11,a12,a21,a22,b1,b2]=AffineTransform(Accept_BC,Accept_BR,Accept_TC,Accept_TR,Num_Accept);
fprintf('%s\n','仿射变换模型参数计算... ...');
% 仿射变换模型参数初始化
A=zeros(1,3);
B=zeros(1,3);
% 仿射变换模型参数计算
W=ones(3,Num_Accept);
for tt=1:Num_Accept
tempy=Accept_TC(tt,1);
W(1,tt)=tempy;
tempx=Accept_TR(tt,1);
W(2,tt)=tempx;
end
A=Accept_BC'*W'*inv(W*W');
B=Accept_BR'*W'*inv(W*W');
a11=A(1,1);
a12=A(1,2);
b1=A(1,3);
a21=B(1,1);
a22=B(1,2);
b2=B(1,3);
fprintf('%s\n','像素重采样... ...');
% 利用计算得到的仿射变换模型参数将实时图像向基准图像重采样 ImageAffined=double(BaseImage);
for i=1:TempHeight
for j=1:TempWidth
row=a21*j+a22*i+b2;
col=a11*j+a12*i+b1;
row=floor(row);
col=floor(col);
if((row>=1)&&(row=1)&&(col
ImageAffined(row,col)=abs(temp-20);
end
end
end
% 将实时图像的四个顶点进行仿射变换模型参数进行变换
row=a21*1+a22*1+b2;
col=a11*1+a12*1+b1;
row_LU=floor(row);
col_LU=floor(col);
row=a21*TempWidth+a22*1+b2;
col=a11*TempWidth+a12*1+b1;
row_RU=floor(row);
col_RU=floor(col);
row=a21*1+a22*TempHeight+b2;
col=a11*1+a12*TempHeight+b1;
row_LD=floor(row);
col_LD=floor(col);
row=a21*TempWidth+a22*TempHeight+b2;
col=a11*TempWidth+a12*TempHeight+b1;
row_RD=floor(row);
col_RD=floor(col);
if(row_LU
row_U=row_LU;
else
row_U=row_RU;
end
if(row_LD>=row_RD)
row_D=row_LD;
else
row_D=row_RD;
end
if(col_LU
col_L=col_LU;
else
col_L=col_LD;
end
if(col_RU>=col_RD)
col_R=col_RU;
else
col_R=col_RD;
end
if(row_U
Start_row=-row_U+1;
else
Start_row=1;
end
if(row_D>=BaseHeight)
End_row=row_D;
else
End_row=BaseHeight;
end
if(col_L
Start_col=-col_L+1;
else
Start_col=1;
end
if(col_R>=BaseWidth)
End_col=col_R;
else
End_col=BaseWidth;
end
AffineHeight=End_row+Start_row;
AffineWidth=End_col+Start_col;
% 配准图像初始化
AffinedImage=zeros(AffineHeight,AffineWidth);
FlagImage=zeros(AffineHeight,AffineWidth);
for i=1:BaseHeight
for j=1:BaseWidth
temp=double(BaseImage(i,j));
AffinedImage(Start_row+i-1,Start_col+j-1)=temp;
FlagImage(Start_row+i-1,Start_col+j-1)=1;
end
end
for i=1:TempHeight
for j=1:TempWidth
row=a21*j+a22*i+b2;
col=a11*j+a12*i+b1;
row=floor(row);
col=floor(col);
row=Start_row+row;
col=Start_col+col;
temp=double(TempImage(i,j));
AffinedImage(row,col)=abs((temp+AffinedImage(row,col)+40)/2); FlagImage(row,col)=1;
end
end
for i=1:BaseHeight
for j=1:BaseWidth
if FlagImage(i,j)==0
AffinedImage(i,j)=(AffinedImage(i-1,j)+AffinedImage(i+1,j)+AffinedImage(i,j-1)+AffinedImage(i,j+1))/4;
end
end
end
AffineImage=uint8(AffinedImage);
figure;
imshow(uint8(AffineImage));
title('配准结果');
% 该函数实现区域之间的匹配
function
[row,col,Cor]=Area_Matched(Image,Area,posr,posc,cnt,Mask,NumC,Step)
row=0;
col=0;
Cor=-1;
% Step
Area=double(Area);
N=2*Step+1;
for ind=1:cnt
index_y=posc(ind,1);
index_x=posr(ind,1);
Temp=double(Image(index_y-Step:index_y+Step,index_x-Step:index_x+Step));
Temp=Temp.*Mask;
sum_area=0;
sum_temp=0;
sum_arte=0;
for ii=1:N
for jj=1:N
if(Mask(ii,jj)==1)
sum_area=sum_area+Area(ii,jj);
sum_temp=sum_temp+Temp(ii,jj);
end
end
end
avg_area=sum_area/NumC;
avg_temp=sum_temp/NumC;
sum_area=0;
sum_temp=0;
sum_arte=0;
for ii=1:N
for jj=1:N
if(Mask(ii,jj)==1)
sum_area=sum_area+(Area(ii,jj)-avg_area)^2;
sum_temp=sum_temp+(Temp(ii,jj)-avg_temp)^2;
sum_arte=sum_arte+abs((Temp(ii,jj)-avg_temp)*(Area(ii,jj)-avg_area));
end
end
end
cor_temp=sum_arte^2/(sum_area*sum_temp);
if(cor_temp>=Cor)
Cor=cor_temp;
row=index_y;
col=index_x;
end
end
function [ImageSel,ImageMask,Cnt]=Circle_Area(Image,Radius)
Cnt=0;
ImageMask=zeros(2*Radius+1,2*Radius+1);
for a=-Radius:Radius
for b=-Radius:Radius
dis=floor(sqrt(a^2+b^2));
if(dis
ImageMask(Radius+1+a,Radius+1+b)=1;
Cnt=Cnt+1;
end
end
end
ImageSel=ImageMask.*double(Image);
ImageSel=uint8(ImageSel);
% 该函数实现对Harris 角点的提取
function [posc, posr,cnt]=harris_corner(ori_im,tt)
% ori_im=ImageData;
%ori_im = imread('arroyo-r.tiff'); % 读取图像
fx = [5 0 -5;8 0 -8;5 0 -5]; % 高斯函数一阶微分,x 方向(用于改进的Harris 角点提取算法)
%fx = [-2 -1 0 1 2]; % x方向梯度算子(用于Harris 角点提取算法)
Ix = filter2(fx,ori_im); % x方向滤波
fy = [5 8 5;0 0 0;-5 -8 -5]; % 高斯函数一阶微分,y 方向(用于改进的Harris 角点提取算法)
% fy = [-2;-1;0;1;2]; % y 方向梯度算子(用于Harris 角点提取算法)
Iy = filter2(fy,ori_im); % y方向滤波
Ix2 = Ix.^2;
Iy2 = Iy.^2;
Ixy = Ix.*Iy;
clear Ix;
clear Iy;
h= fspecial('gaussian',[7 7],2); % 产生7*7的高斯窗函数,sigma=2
Ix2 = filter2(h,Ix2);
Iy2 = filter2(h,Iy2);
Ixy = filter2(h,Ixy);
height = size(ori_im,1);
width = size(ori_im,2);
result = zeros(height,width); % 纪录角点位置,角点处值为1
R = zeros(height,width);
Rmax = 0; % 图像中最大的R 值
for i = 1:height
for j = 1:width
M = [Ix2(i,j) Ixy(i,j);Ixy(i,j) Iy2(i,j)]; % auto correlation matrix
R(i,j) = det(M)-0.06*(trace(M))^2; % 计算R if R(i,j) > Rmax
Rmax = R(i,j);
end;
end;
end;
cnt = 0;
for i = 2:height-1
for j = 2:width-1
% 进行非极大抑制,窗口大小3*3
if R(i,j) > tt*Rmax && R(i,j) > R(i-1,j-1) && R(i,j) > R(i-1,j) && R(i,j) > R(i-1,j+1) && R(i,j) > R(i,j-1) && R(i,j) > R(i,j+1) && R(i,j) > R(i+1,j-1) && R(i,j) > R(i+1,j) && R(i,j) > R(i+1,j+1)
result(i,j) = 1;
cnt = cnt+1;
end;
end;
end;
% size(result)
[posc, posr] = find(result == 1);
% cnt % 角点个数
% imshow(ori_im);
% hold on;
% plot(posr,posc,'r+');
% 该函数实现坐标差值统计
function [Num,Num_cumu,Histed]=HistData(NumPoints,MatrixPoints)
Num=0;
for i=1:NumPoints
temp=MatrixPoints(i,1);
if(Num==0)
Num=Num+1;
% temp=MatrixPoints_matched(i,3);
Histed(1,Num)=temp;
Num_cumu(1,Num)=1;
else
k=1;
while(k
tempp=Histed(1,k);
if(abs(temp-tempp)
Num_cumu(1,k)=Num_cumu(1,k)+1;
break;
else
k=k+1;
end
end
if(k>Num)
Num=Num+1;
Histed(1,Num)=temp; Num_cumu(1,Num)=1; end
end
end