본문 바로가기
정보 보안/지문 & 홍채인식 프로젝트

alignment 함수 - 지문인식

by tryotto 2020. 2. 5.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function newMinutiae2 = alignment(Minutiae, Minutiae2)
num1 = size(Minutiae,1);   
num2 = size(Minutiae2,1);   
A(1:24,1:59,1:59)=0;
 
for i=1:num1
    type1 = Minutiae(i,3);
    for j=1:num2                
        type2 = Minutiae2(j,3);
        if type1~=type2            
            continue;
        end
                
        theta = Minutiae(i,4)-Minutiae2(j,4);
        delX = floor(Minutiae(i,2)-Minutiae2(j,2)*cos(theta)-Minutiae2(j,1)*sin(theta)) + 30;
        delY = floor(Minutiae(i,1)+Minutiae2(j,2)*sin(theta)-Minutiae2(j,1)*cos(theta)) + 30;                
        tmp = floor((Minutiae(i,4)/pi)*180)-floor((Minutiae2(j,4)/pi)*180);        
        
        if(delX<20 && delY<20 && delX>0 && delY>0)
            tmp = floor((Minutiae(i,4)/pi)*180)-floor((Minutiae2(j,4)/pi)*180);        
            if tmp<-180
                tmp = tmp + 360;            
            elseif tmp>180
                tmp = tmp - 360;
            end
            idx = toIdx(tmp);
            
            A(idx,delY,delX)=A(idx,delY,delX)+1;            
        end        
    end
end
 
maxV=0;
rstX=0;
rstY=0;
rstTheta=0;
for i=1:24
    for j=1:59
        for k=1:59
           if maxV<A(i,j,k)
               maxV=A(i,j,k);
               rstTheta=totheta(i);        
               rstY=j-30;
               rstX=k-30;
           end
        end
    end
end
 
newMinutiae2=[];
for j=1:num2
    tmpTh = floor((Minutiae2(j,4)/pi)*180)-floor((rstTheta/pi)*180);        
    if tmpTh>180
        tmpTh = tmpTh-360;
    end
    if tmpTh<-180
        tmpTh = tmpTh+360;
    end
    
    tmpY=Minutiae2(j,1)-rstY;
    tmpX=Minutiae2(j,2)-rstX;
    typeNew=Minutiae2(j,3);
    
    tmpIdx=toIdx(tmpTh);
    tmpTh=totheta(tmpIdx);
    
    newMinutiae2=[newMinutiae2;[tmpY,tmpX,typeNew,tmpTh]];
end
 
end
cs