complete.m
上传用户:shlz_zpc
上传日期:2020-12-28
资源大小:1111k
文件大小:5k
源码类别:

生物技术

开发平台:

Matlab

  1. load anonymous.mat;
  2. load im1.mat;
  3. load im2.mat;
  4. load im3.mat;
  5. %data conversion of the 'pct' provided images
  6. convert1=fopen('villain_1.pct');                  
  7. char=fread(convert1,297,'char');                
  8. unit8=fread(convert1,[512 512],'uint8');                 
  9. transpose=unit8';                                                  
  10. convert1=fopen('villain_2.pct');                  
  11. char=fread(convert1,297,'char');                
  12. unit8=fread(convert1,[512 512],'uint8');                 
  13. transpose1=unit8';                                                  
  14. convert1=fopen('villain_3.pct');                  
  15. char=fread(convert1,297,'char');                
  16. unit8=fread(convert1,[512 512],'uint8');                 
  17. transpose2=unit8';                                                  
  18. subplot(2,3,2),imshow(crime),title('corrupted fingerprint');
  19. subplot(2,3,4),imshow(transpose,[0 255]),title('villain1');
  20. subplot(2,3,5),imshow(transpose1,[0 255]),title('villain2');
  21. subplot(2,3,6),imshow(transpose2,[0 255]),title('villain3');
  22. %filtration of noise involved
  23. filt1=medfilt2(crime,[5 5],'symmetric');
  24. filt2=ordfilt2(filt1,5,ones(3,3));
  25. filt3=medfilt2(filt2,[4 4],'symmetric');
  26. threshold=graythresh(filt3);
  27. conversion=im2bw(filt3,threshold);
  28. figure,subplot(2,2,1),imshow(filt1),title('5x5 median filter');
  29. subplot(2,2,2),imshow(filt2),title('ordinary filter');
  30. subplot(2,3,5),imshow(filt3),title('4x4 median filter');
  31. %to extract the size and location features
  32. construct=strel('square',4);
  33. close=imclose(conversion,construct);
  34. close1=imclose(close,construct);
  35. [M,N]=find(close1==0);
  36. T=min(min(M));
  37. B=max(max(M));
  38. L=min(min(N));
  39. R=max(max(N));
  40. RA1=(B-T)/2;
  41. RA2=(R-L)/2;
  42. if(RA1>=RA2)
  43.     RA=RA2;
  44. else
  45.     RA=RA1;
  46. end
  47. X=L+RA;
  48. Y=T+RA;
  49. [m,n] = size(crime);
  50. CI=zeros([m,n]);
  51. for N=1:m
  52.   for M=1:n
  53.     if((N-X)^2+(M-Y)^2<=RA^2)
  54.         CI(M,N)=1;
  55.     end
  56.   end
  57. end
  58. CI1=CI.*double(filt2);
  59. CI1=uint8(CI1);
  60. rotation=imrotate(CI1,-30,'crop');
  61. divide=RA/1.414;
  62. divide=fix(divide);
  63. RO=rotation((Y-divide):(Y+divide),(X-divide):(X+divide));
  64. figure,subplot(2,2,1),imshow(close),title('Morphological close');
  65. subplot(2,2,2),imshow(CI),title('Circle in black square');
  66. subplot(2,2,3),imshow(CI1),title('Combination');
  67. subplot(2,2,4),imshow(RO),title('Feature extraction');
  68. %feature matching of the corrupted and archived fingerprints
  69. filt1=medfilt2(crime,[5 5], 'symmetric');
  70. filt2=medfilt2(crime,[7 7], 'symmetric');
  71. filt3=ordfilt2(filt1,5,ones(3 ,3));
  72. mod=medfilt2(filt3,[4 4]);
  73. ba=find(mod>130 & filt2<140); 
  74. [r,c]=size(mod);
  75. ar=r*c;
  76. ci= ar-length(ba);
  77. ra=sqrt(ci/pi);
  78. ra=round(ra);
  79. mod=double(mod);
  80. fc=mod ./255;
  81. im=ci .* fc;
  82. S=2*ra*cos(pi/4);
  83. S=round(S);
  84. rotation=imrotate(im,-30,'bilinear');
  85. [r,c]=size(rotation);
  86. Ee=round((c+1)/2);
  87. Tt=round((r+1)/2);
  88. b=Ee-(S/2);
  89. i=Tt-(S/2);
  90. b=round(b);
  91. i=round(i);
  92. region=imcrop(rotation,[b, i, S, S]);
  93. cc1= zeros(356);
  94. for col=1:356     
  95.     for row=1:356
  96.         cc1(row,col)=corr2(region, im1(row:row+156, col:col+156)); 
  97.     end
  98. end
  99. maximum1=max(max(cc1));
  100. maximum1         
  101. cc2= zeros(356);
  102. for col=1:356
  103.     for row=1:356
  104.         cc2(row,col)=corr2(region, im2(row:row+156, col:col+156));
  105.     end
  106. end
  107. maximum2=max(max(cc2));
  108. maximum2
  109. cc3=zeros(356);
  110. for col=1:356
  111.     for row=1:356
  112.         cc3(row,col)=corr2(region,im3(row:row+156, col:col+156));
  113.     end
  114. end
  115. maximum3=max(max(cc3));
  116. maximum3
  117. if(maximum1>=maximum2)
  118.     maximum=maximum1;
  119.     [row,col]=find(cc1==maximum);
  120.     res=im1(row:row+S, col:col+S);
  121.     figure, imshow(res), title('Matching Villain 1');
  122. else
  123.     maximum=maximum2;
  124.     [row,col]=find(cc2==maximum);
  125.     res=im2(row:row+S, col:col+S);
  126.     figure, imshow(res), title('Matching Villain 2');
  127. end
  128. if(maximum>=maximum3)
  129.     maximum=maximum
  130. else maximum=maximum3;
  131.     [row,col]=find(cc3==maxm);
  132.     res=im3(row:row+S,col:col+S);
  133.     figure, imshow(res), title('Matching Villain 3');
  134. end
  135. %feature classification of the matching found and the processed fingerprint
  136. region=RO;
  137.  [m n]=size(RO);
  138.  if (maximum1>=maximum2)
  139.  maximum=maximum1;
  140.     [row,col] = find(cc1==maximum);
  141.    res=im1(row:row+m,col:col+n);
  142.    figure,imshow(res),title('Matching Villain 1');
  143.    else
  144.     maximum=maximum2;
  145.     [row,col] = find(cc2==maximum);
  146.    res=im2(row:row+m,col:col+n);
  147.    figure,imshow(res),title('Matching Villain 2');
  148.    end
  149. if( maximum>=maximum3)
  150.     maximum=maximum;
  151. else
  152.     maximum=maximum3;
  153.      [row,col] = find(cc3==maximum);
  154.   res=im3(row:row+m,col:col+n);
  155.   figure,imshow(res),title('Matching Villain 3');
  156.   end
  157. SUBPLOT(1,2,1),imshow(region);title('After processing');
  158. SUBPLOT(1,2,2),imshow(res);title('After matching');