complete.m
资源名称:report3.rar [点击查看]
上传用户:shlz_zpc
上传日期:2020-12-28
资源大小:1111k
文件大小:5k
源码类别:
生物技术
开发平台:
Matlab
- load anonymous.mat;
- load im1.mat;
- load im2.mat;
- load im3.mat;
- %data conversion of the 'pct' provided images
- convert1=fopen('villain_1.pct');
- char=fread(convert1,297,'char');
- unit8=fread(convert1,[512 512],'uint8');
- transpose=unit8';
- convert1=fopen('villain_2.pct');
- char=fread(convert1,297,'char');
- unit8=fread(convert1,[512 512],'uint8');
- transpose1=unit8';
- convert1=fopen('villain_3.pct');
- char=fread(convert1,297,'char');
- unit8=fread(convert1,[512 512],'uint8');
- transpose2=unit8';
- subplot(2,3,2),imshow(crime),title('corrupted fingerprint');
- subplot(2,3,4),imshow(transpose,[0 255]),title('villain1');
- subplot(2,3,5),imshow(transpose1,[0 255]),title('villain2');
- subplot(2,3,6),imshow(transpose2,[0 255]),title('villain3');
- %filtration of noise involved
- filt1=medfilt2(crime,[5 5],'symmetric');
- filt2=ordfilt2(filt1,5,ones(3,3));
- filt3=medfilt2(filt2,[4 4],'symmetric');
- threshold=graythresh(filt3);
- conversion=im2bw(filt3,threshold);
- figure,subplot(2,2,1),imshow(filt1),title('5x5 median filter');
- subplot(2,2,2),imshow(filt2),title('ordinary filter');
- subplot(2,3,5),imshow(filt3),title('4x4 median filter');
- %to extract the size and location features
- construct=strel('square',4);
- close=imclose(conversion,construct);
- close1=imclose(close,construct);
- [M,N]=find(close1==0);
- T=min(min(M));
- B=max(max(M));
- L=min(min(N));
- R=max(max(N));
- RA1=(B-T)/2;
- RA2=(R-L)/2;
- if(RA1>=RA2)
- RA=RA2;
- else
- RA=RA1;
- end
- X=L+RA;
- Y=T+RA;
- [m,n] = size(crime);
- CI=zeros([m,n]);
- for N=1:m
- for M=1:n
- if((N-X)^2+(M-Y)^2<=RA^2)
- CI(M,N)=1;
- end
- end
- end
- CI1=CI.*double(filt2);
- CI1=uint8(CI1);
- rotation=imrotate(CI1,-30,'crop');
- divide=RA/1.414;
- divide=fix(divide);
- RO=rotation((Y-divide):(Y+divide),(X-divide):(X+divide));
- figure,subplot(2,2,1),imshow(close),title('Morphological close');
- subplot(2,2,2),imshow(CI),title('Circle in black square');
- subplot(2,2,3),imshow(CI1),title('Combination');
- subplot(2,2,4),imshow(RO),title('Feature extraction');
- %feature matching of the corrupted and archived fingerprints
- filt1=medfilt2(crime,[5 5], 'symmetric');
- filt2=medfilt2(crime,[7 7], 'symmetric');
- filt3=ordfilt2(filt1,5,ones(3 ,3));
- mod=medfilt2(filt3,[4 4]);
- ba=find(mod>130 & filt2<140);
- [r,c]=size(mod);
- ar=r*c;
- ci= ar-length(ba);
- ra=sqrt(ci/pi);
- ra=round(ra);
- mod=double(mod);
- fc=mod ./255;
- im=ci .* fc;
- S=2*ra*cos(pi/4);
- S=round(S);
- rotation=imrotate(im,-30,'bilinear');
- [r,c]=size(rotation);
- Ee=round((c+1)/2);
- Tt=round((r+1)/2);
- b=Ee-(S/2);
- i=Tt-(S/2);
- b=round(b);
- i=round(i);
- region=imcrop(rotation,[b, i, S, S]);
- cc1= zeros(356);
- for col=1:356
- for row=1:356
- cc1(row,col)=corr2(region, im1(row:row+156, col:col+156));
- end
- end
- maximum1=max(max(cc1));
- maximum1
- cc2= zeros(356);
- for col=1:356
- for row=1:356
- cc2(row,col)=corr2(region, im2(row:row+156, col:col+156));
- end
- end
- maximum2=max(max(cc2));
- maximum2
- cc3=zeros(356);
- for col=1:356
- for row=1:356
- cc3(row,col)=corr2(region,im3(row:row+156, col:col+156));
- end
- end
- maximum3=max(max(cc3));
- maximum3
- if(maximum1>=maximum2)
- maximum=maximum1;
- [row,col]=find(cc1==maximum);
- res=im1(row:row+S, col:col+S);
- figure, imshow(res), title('Matching Villain 1');
- else
- maximum=maximum2;
- [row,col]=find(cc2==maximum);
- res=im2(row:row+S, col:col+S);
- figure, imshow(res), title('Matching Villain 2');
- end
- if(maximum>=maximum3)
- maximum=maximum
- else maximum=maximum3;
- [row,col]=find(cc3==maxm);
- res=im3(row:row+S,col:col+S);
- figure, imshow(res), title('Matching Villain 3');
- end
- %feature classification of the matching found and the processed fingerprint
- region=RO;
- [m n]=size(RO);
- if (maximum1>=maximum2)
- maximum=maximum1;
- [row,col] = find(cc1==maximum);
- res=im1(row:row+m,col:col+n);
- figure,imshow(res),title('Matching Villain 1');
- else
- maximum=maximum2;
- [row,col] = find(cc2==maximum);
- res=im2(row:row+m,col:col+n);
- figure,imshow(res),title('Matching Villain 2');
- end
- if( maximum>=maximum3)
- maximum=maximum;
- else
- maximum=maximum3;
- [row,col] = find(cc3==maximum);
- res=im3(row:row+m,col:col+n);
- figure,imshow(res),title('Matching Villain 3');
- end
- SUBPLOT(1,2,1),imshow(region);title('After processing');
- SUBPLOT(1,2,2),imshow(res);title('After matching');