📄 trajetory.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function: 掌纹图像预处理程序之迹线跟踪算法
% Author: 温长芝
% Date: 2006/12/7
% Copyright: 西南交通大学 信号与信息处理四川省重点实验室
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% function Cropedimage_algorithm_1_main()
% 第一种算法现在用的比较多的,即张大鹏同志在论文中提到的迹线跟踪算法;
% 首先用顺序统计滤波器对掌纹图像进行滤波。然后,设定合适的阈值将图像二值化。
% 用‘canny’算子提取图像的轮廓。首先确定要跟踪的迹线的起始点和结束点。
% 起始点和结束点的提取采用的是李文新教授所提供的程序中使用的方法。
% 接下来就要提取两个手指之间的弧线。文献中用的是迹线跟踪的算法。
% 计算起始点和结束点的中点的坐标,及所提取弧线所有点的重心的坐标。
% 连接着两个点,确定一条直线。计算这条直线与弧线的交点即为所要求的基准点。
%
% (a)原始掌纹图像 经 (b)顺序统计滤波后的图像;(c)二值化;(d)canny算子提取轮廓;
% (e)找到的两条弧线的重心和起始点结束点的中点;(f)切割出的掌纹中心部分的图像。
%
function Cropedimage_algorithm_1_main()
clear,close all;
clc;
RR=40;
CC=20; % 找到中心坐标后,确定切割图像左上角点所用的参数
M=20; % 用于确定起始点的坐标
for i=9
for j=1
im=imread(strcat('PolyU_',num2str(i),'_S_',num2str(j),'.bmp'));
subplot(2,3,1);
imshow(im);
title('(a) 原始掌纹图像');
[outimage,kk,x,y,xx,yy]=cut_image(im,M);
% 确定三个手指的位置,三个起始点和三个结束点的坐标。
origin_image=im(M:270,kk:kk+270); % 对原始掌纹图像进行切割
Point_first=C_point(outimage,x,y);
Point_second=C_point(outimage,xx,yy); % 得到两段弧线的重心坐标
S_X=size(outimage,1);
S_Y=size(outimage,2); % 图像的大小
% 确定第一个手指的角点作为基准点1
r1=round(Point_first(1)); % 弧线的重心
c1=round(Point_first(2));
r2=round((x+y)/2); % 起始点和结束点的中点坐标
c2=1;
P_1=[];
outimage=uint8(outimage);
for r=1:S_X
c=round((r-r2)*(c2-c1)/(r2-r1)+c2); % 连接两个点,拟和一条直线
if ( r<100 && c>1 && c<100 && outimage(r,c)==1 )
P_1=[r c]; % 找到曲线与直线的交点即为所求的点
outimage(r,c)=101; % 对找到的基准点标记
break
end
end
if (isempty(P_1))
for c=1:S_Y
r =round((c-c2)*(r2-r1)/(c2-c1)+r2);% 拟和一条直线
if ( r>1 && r<100 && c<100 && outimage(r,c)==1 )
P_1=[r c]; % 找到曲线与直线的交点即为所求的点
outimage(r,c)=101; % 对找到的基准点标记
break;
end
end
end
% 确定第二个手指的角点作为基准点2
rr1=round(Point_second(1));
cc1=round(Point_second(2));
rr2=round((xx+yy)/2);
cc2=1;
P_2=[];
for cc=1:S_Y
rr =round((cc-cc2)*(rr2-rr1)/(cc2-cc1)+rr2); % 拟和一条直线
if (rr>1&&rr<S_X&&outimage(rr,cc)==1)
P_2=[rr cc]; % 找到曲线与直线的交点即为所求的点
outimage(rr,cc)=101; % 对找到的基准点标记
break;
end
end
% 连接两个基准点,其连线作为x轴其中点作为坐标原点
if (cc>c)
angle=atan((cc-c)/(r-rr))*360/2/pi;
else
angle=atan((c-cc)/(r-rr))*360/2/pi;
end
origin_rotate=imrotate(origin_image,angle,'crop'); % 旋转
outimage_rotate=imrotate(outimage,angle,'crop');
[r0 c0]=find(outimage_rotate==101); % 在旋转后的图像上找到标记的基准点
if (isempty(r0)||isempty(r0)) % 如果旋转后的图像上找不到标记的基准点
[r0 c0]=find(outimage==101); % 则使用为旋转图像上的基准点
end
R_0=mean(r0)-RR;
C_0=mean(c0)+CC;
image_crop=imcrop(origin_rotate,[R_0,C_0,127,127]);
imwrite(image_crop,strcat('P_S', num2str(i) ,'_' ,num2str(j),'.bmp'));
% figure(4);
% imshow(image_crop);
end
end
subplot(2,3,5);
imshow(image_crop);
title('(f) 切割出的图像');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: 温长芝
% Date: 2006/12/7
% Copyright: 西南交通大学 信号与信息处理四川省重点实验室
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% function [output]=C_point(image,S,E)
% This function is used to get two basis points between fingers
% 采用轮廓跟踪法,得到两条曲线的坐标集,再通过求质心确定两个基准点
%
% Input Parameters:
%
% image --- 输入的图像
% S,E --- 起始点和终点的纵坐标
%
% Output Parameters:
%
% output --- 提取弧线所有点的重心坐标
%
function [output]=C_point(image,S,E)
n=0; % the number of points on the first curve
B_point=[];% the matrix which contain the coordination of the boundary
D_cw=[-1 1;0 1; 1 1; 1 0; 1 -1; 0 -1; -1 -1;-1 0;
-1 1;0 1; 1 1; 1 0; 1 -1; 0 -1; -1 -1;-1 0; ];
Temp=[S 2];% the begining point
temp=[];
for i=1:5
temp=Temp+D_cw(i,:); % 探寻起始点的八邻域邻点
if (image(temp(1),temp(2))==1) % 判断是否为边界点
Temp=temp;
break; % 找到第一个边界点,中止循环
end
B_point=[B_point;Temp]; % 将找到的点放到边界矩阵中
n=n+1; % 计数
end
begin=1;
while(~((Temp(1)==E)&&(Temp(2)==2))) % 若是结束点,则中止
for i=0:4
temp=Temp+D_cw(begin+i,:); % 探寻其八邻域内的点
if (n>3)
if (temp==B_point(n-1,:)) % 若找到下一点与前一点相同,则旋转180度
begin=4;
end
end
if (image(temp(1),temp(2))==1) % 如果为边界点,则把下一点作为当前点
Temp=temp;
break;
end
B_point=[B_point;Temp]; % 把找到的点放到边界矩阵中
n=n+1;
end
end
X_point=sum(B_point(:,1))/size(B_point,1);% 确定曲线点集的中心
Y_point=sum(B_point(:,2))/size(B_point,1);
output=[X_point Y_point];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: 温长芝
% Date: 2006/12/7
% Copyright: 西南交通大学 信号与信息处理四川省重点实验室
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% function [outimage,kk,S_1,E_1,S_2,E_2]=cut_image(input_image,M)
% this function use new algorithm to get the ROI of palmprint
% wenchangzhi 2006/12/7
% 确定三个手指的位置,三个起始点和三个终点的坐标。
% 这六个点中的四个将作为下个函数的输入
%
% Input Parameters:
%
% input_image --- 原始掌纹图像
% M --- 确定起始点的坐标
%
% Output Parameters:
%
% kk,S_1,E_1,S_2,E_2 --- 两段弧线的起始点和结束点坐标
% outimage --- canny算子提取轮廓后的图像
%
function [outimage,kk,S_1,E_1,S_2,E_2]=cut_image(input_image,M)
im=input_image;
im=ordfilt2(im,200,ones(10,40)); % 低通中值滤波 顺序统计滤波
imwrite(im,'ordfilt_image.bmp');
subplot(2,3,2);
imshow(im);
title('(b) 顺序统计滤波后的图像');
im(find(im<15))=0;
im(find(im>=15))=255; % 图像二值化
imwrite(im,'binary_image.bmp');
subplot(2,3,3);
imshow(im);
title('(c) 图像二值化');
for j=1:384
if im(M,j)==255
break;
end
end
for jj=1:384
if im(270,jj)==255
break;
end
end
if j>jj
k=j;
else if (jj<100)
k=jj;
end
end
k=j;
image_new=im(M:270,k:k+270); % 取图像中心的一部分
image_new=edge(image_new,'canny');
imwrite(image_new,'image_edge.bmp');
subplot(2,3,4);
imshow(image_new);
title('(d) canny算子轮廓图像');
c=[];
[r c]=find(image_new(:,2)==1);
s_r=length(r);
s1=r(1); % 两段弧线的起始点和结束点坐标
e1=r(2);
s2=r(s_r-1);
e2=r(s_r);
outimage=image_new;
kk=k;
S_1=s1;E_1=e1;
S_2=s2;E_2=e2;
% http://hi.baidu.com/huangwen2003/blog/ 静进心——掌纹识别手掌静脉识别专题 生物特征识别专题 % 西南交通大学
%
% 掌纹识别 定位分割 形态学腐蚀膨胀算法 matlab源码 西南交通大学 温长芝
% 掌纹识别 定位分割 迹线跟踪算法 matlab源码 西南交通大学 温长芝
% 掌纹识别 基于最大内切圆的定位分割算法
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -