% OCL Compute the orientation certainity level of fingerprint image.
%
% Function to assess the quality of fingerprint image
%
% Usage: [score] = ocl(f, blocksize);
%
% Argument: im - Fingerprint image to be assessed.
% blocksize - the scale of the block which will be assessed.
%
% Returns: score - the score of the fingerprint image being assessed.
%
%
% Jerry Zhao & Li Xiutao
% School of Computer Science & Software Engineering
% Si Chuan University
% http://www.qijunzhao.org
%
% January 2013
function [ocl] = ocl(f, blocksize)
if ~(nargin == 1 || nargin == 2)
error('Usage: [score] = ocl(im, blocksize)');
end
ocl = 0;
f=double(f);
[m n]=size(f);
row=m-mod(m,blocksize);
column=n-mod(n,blocksize);
oclPerBlock=zeros(row/blocksize,column/blocksize)+100;
%numberOfBlock = (row/32)*(column/32);
n=0;
NO =0;%记录可计算的block的数目。
for i=1:blocksize:row-1
for j=1:blocksize:column-1
M = f(i:i+blocksize-1,j:j+blocksize-1);
[Fx, Fy] = gradient(M);
C = [0,0;0,0];
for h=1:blocksize
C = C+[Fx(h);Fy(h)]*[Fx(h),Fy(h)];
end
C = C/(32*32);
a = C(1); b = C(4); c = C(2);
lmin = ((a+b)-sqrt((a-b)^2 + 4*c^2))/2;
lmax = ((a+b)+sqrt((a-b)^2 + 4*c^2))/2;
n=n+1;
if ~(lmax == 0)
NO = NO+1;
ocl = lmin/lmax;
oclPerBlock(n) = ocl;
end
end
end
ocl = ocl/NO;
n=0;
f = cat(3,f,f,f);
for i=1:blocksize:row-1
for j=1:blocksize:column-1
f =drawRect(f,[i,j],[32,32],'r',1);
end
end
f = uint8(drawRect(f,[0,0],[32,32],'r',1));
imshow(f)
hold on
for h=1:(row/blocksize)
for k=1:(column/blocksize)
n = n+1;
text((k-1)*blocksize+blocksize/2,(h-1)*blocksize+blocksize/2,num2str(oclPerBlock(n)),'color','r');
end
end