matlab - Implementing a fingerprint quality measure? -


i trying implement spatial domain fingerprint quality analysis. quality measure shown in below:

enter image description here

i able implement till equation 9. next step calculate weight shown in equation 11. when tried implementing weights zero. of great if me fix issue. have attached code below:

clc;clear all;close all; img = imread('c:\users\shrey\google drive\quality\testdatabase\fvc2004\db1_b\101_2.tif'); b = 2; br=1;  img=finger_segment(img); img(img==0.5)=0;  [gx,gy]=gradient(img);  = 1 :b: size(img,1)     j = 1 :b: size(img,2) % gradients blockwise         gx1 = gx(i:min(i+b-1,size(gx,1)),j:min(j+b-1,size(gx,2)));         gy1 = gy(i:min(i+b-1,size(gy,1)),j:min(j+b-1,size(gy,2)));         temp = img(i:min(i+b-1,size(img,1)),j:min(j+b-1,size(img,2)));         if (any(any(temp)) == 1)             k(br) = coherence_grad_3(gx1,gy1,b);             temp2=temp/sum(temp(:)); % centroid calculation             [r1,c1]=size(temp);             [i,j]=ndgrid(1:r1,1:c1);             li(br,:)=[dot(i(:),temp2(:)),dot(j(:),temp2(:))];             li1(br,1)=li(br,1)+ (i-1);             li1(br,2)=li(br,2)+ (j-1);             br = br + 1;         end     end end  %% finding centroid of whole image k(isnan(k))=0; mask = zeros(size(img)); mask(img>0)=1; % mask find centroid of foreground imgcent=mask/sum(mask(:)); [r1,c1]=size(mask); [i,j]=ndgrid(1:r1,1:c1); lc=[dot(i(:),imgcent(:)),dot(j(:),imgcent(:))];  %% relative weight sub=bsxfun(@minus, lc, li); c=1:br-1     num(c) =(norm(sub(c,:))); end c=1:br-1      wi(c) = exp(-(num(c).^2)/2*5); end q = (1/br) * sum(wi.*k);    functions above code % coherence matrix equation 7 code: function k1= coherence_grad_3(gx,gy,b) %untitled3 summary of function goes here %   detailed explanation goes here j=0;  = 1:size(gx,1)     j = 1:size(gx,2)         gs=[gx(i,j),gy(i,j)]';         j= gs* gs' + j;     end end  j= (j/(b.^2)); l = eig(j); k1 = ((l(1)-l(2)).^2)/((l(1)+l(2)).^2);  end   % segmentation program function f3=finger_segment(h) if(ndims(h)==3)     h= rgb2gray(h); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % function segment fingerprint image using morphological processing. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  h=im2double(h);  %%% step 1: feature extraction h1=rangefilt(h);   %%% convert binary image h2=adaptivethreshold(h1,16,0.05,0);  %%% step 2: morphological processing se = strel('disk', 6, 4); h3=imclose(~h2,se); h4=imopen(h3,se); h4 = imfill(h4,'holes'); se1=strel('square',12); h4=imerode(h4,se1); [m1,n1] = size(h); f=zeros(m1,n1); [l, num] = bwlabel(h4,8); max1=0; j=1:num [r, c] = find(bwlabel(l)==j); m=size(r,1); if (max1<m)     id=j;     max1=m; end end [r, c] = find(bwlabel(l)==id); s3=size(r,1); i=1:s3     f(r(i),c(i))=1; end  %%% step 3: contour smoothing erf=boundaries(f); erf=erf{1}; z=frdescp(erf); z1=ifrdescp(z,50); x = round(z1(:, 1));  y = round(z1(:, 2)); if(min(x)<=0)       x = x - min(x) + 1; end if (min(y)<=0)       y = y - min(y) + 1; end  zz=zeros(m1,n1); ii=1:size(z1,1)     zz(x(ii),y(ii))=1; end  se1=strel('square',3); zz=imdilate(zz,se1);  [r1, c1] = find(zz==1); zz=imfill(zz,'holes');  i=1:m1   j=1:n1       if(zz(i,j)==1)           f3(i,j)=h(i,j);       else           f3(i,j)=0.5;       end   end end    function bw=adaptivethreshold(im,ws,c,tm)  if (nargin<3)     error('you must provide image im, window size ws, , c.'); elseif (nargin==3)     tm=0; elseif (tm~=0 && tm~=1)     error('tm must 0 or 1.'); end  im=mat2gray(im);  if tm==0     mim=imfilter(im,fspecial('average',ws),'replicate'); else     mim=medfilt2(im,[ws ws]); end sim=mim-im-c; bw=im2bw(sim,0); bw=imcomplement(bw);  function b = boundaries(bw, conn, dir)    if nargin < 3       dir = 'cw'; end  if nargin < 2       conn = 8; end l = bwlabel(bw, conn); numobjects = max(l(:)); if numobjects > 0    b = {zeros(0, 2)};    b = repmat(b, numobjects, 1); else    b = {};   end  lp = padarray(l, [1 1], 0, 'both');  m = size(lp, 1); if conn == 8         offsets = [-1, m - 1, m, m + 1, 1, -m + 1, -m, -m-1]; else        offsets = [-1, m, 1, -m];     end   if conn == 8        next_search_direction_lut = [8 8 2 2 4 4 6 6];    else        next_search_direction_lut = [4 1 2 3];    end   if conn == 8        next_direction_lut = [2 3 4 5 6 7 8 1];   else    next_direction_lut = [2 3 4 1];   end  start    = -1; boundary = -2;  scratch = zeros(100, 1);  [rr, cc] = find((lp(2:end-1, :) > 0) & (lp(1:end-2, :) == 0)); rr = rr + 1;     k = 1:length(rr)        r = rr(k);       c = cc(k);       if (lp(r,c) > 0) & (lp(r - 1, c) == 0) & isempty(b{lp(r, c)})        idx = (c-1)*size(lp, 1) + r;         = lp(idx);         scratch(1) = idx;       lp(idx) = start;         numpixels = 1;           currentpixel = idx;       initial_departure_direction = [];       done = 0;        next_search_direction = 2;           while ~done             direction = next_search_direction;           found_next_pixel = 0;          k = 1:length(offsets)             neighbor = currentpixel + offsets(direction);             if lp(neighbor) ~= 0                    if (lp(currentpixel) == start) & ...                        isempty(initial_departure_direction)                    initial_departure_direction = direction;                            elseif (lp(currentpixel) == start) & ...                        (initial_departure_direction == direction)                    done = 1;                   found_next_pixel = 1;                   break;                end                next_search_direction = ...                      next_search_direction_lut(direction);                found_next_pixel = 1;                numpixels = numpixels + 1;                   if numpixels > size(scratch, 1)                   scratch(2*size(scratch, 1)) = 0;                end                scratch(numpixels) = neighbor;                if lp(neighbor) ~= start                   lp(neighbor) = boundary;                  end                  currentpixel = neighbor;                break;                end             direction = next_direction_lut(direction);          end              if ~found_next_pixel              numpixels = 2;             scratch(2) = scratch(1);                 done = 1;          end           end        [row, col] = ind2sub(size(lp), scratch(1:numpixels));       b{which} = [row - 1, col - 1];        end   end if strcmp(dir, 'ccw')    k = 1:length(b)         b{k} = b{k}(end:-1:1, :);     end   end  function z = frdescp(s)   [np, nc] = size(s);  if nc ~= 2      error('s must of size np-by-2.');  end  if np/2 ~= round(np/2);    s(end + 1, :) = s(end, :);       np = np + 1;  end  x = 0:(np - 1);  m = ((-1) .^ x)';         s(:, 1) = m .* s(:, 1);  s(:, 2) = m .* s(:, 2);  s = s(:, 1) + i*s(:, 2);     z = fft(s);  function s = ifrdescp(z, nd)      np = length(z);   if nargin == 1 | nd > np     nd = np;      end  x = 0:(np - 1);  m = ((-1) .^ x)';     d = round((np - nd)/2);  z(1:d) = 0;  z(np - d + 1:np) = 0;     zz = ifft(z);    s(:, 1) = real(zz);  s(:, 2) = imag(zz);   s(:, 1) = m.*s(:, 1);    s(:, 2) = m.*s(:, 2); 

thanks in advance.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -