Search code examples
matlabfingerprint

How to choose a block of fingerprint around core region?


I have to design a system using fingerprint matching, the algorithm I am using asks to first select a region around core point and then do the manipulations. Now I have got an algorithm page 92from this link that selects the core point and it is working quite fine in terms of core point detection, but my problem is related to crop the image around the core point. Suppose if the core point that I got is wrong or is located at the edge of the image, then when I try to crop the image the image that I got does not have the region that I require, for example let me try to explain this by an image

Suppose I have this image and I want to take its core point

my algorithm gives me a wrong core point (shown in red)

But this is not an issue as I am expecting design to cope up with such wrong core points detection. Now as I mentioned earlier I need to have a region around this core point the command that I am using to give me that region is:

[XofCenter,YofCenter]=get_core(x);
x = imcrop(x,[(XofCenter-128/2) (YofCenter-128/2) 128 128]);

where get_core give me the core points and imcrop gives a block of 128 cross 128 image around core point, which gives me But this is not what I want. I want my image to include more region of fingerprint, even if that means taking my core point not as a center of my block image, some thing like this: enter image description here Now Issue is how to get such thing without manually cropping the image, can somebody help me?


Solution

  • this is a rather simple approach to your problem using imfilter:

    % read image and set wrong core point
    im = im2double(imread('fingerprint.png'));
    wrong_corepoint = [64 77];
    cropsize = 128;
    % filter image to get accumulated values in 128X128 rects
    res = imfilter(im, ones(cropsize),'replicate');
    % get possible cropping area
    yxmin = max([1 1],wrong_corepoint([2 1]) - cropsize + 1);
    yxmax = min(size(im),wrong_corepoint([2 1]) + cropsize - 1);
    % crop filterd image
    res_crop = res(yxmin(1):yxmax(1),yxmin(2):yxmax(2));
    % get minimum value because fingerprint is black
    [v,minidx] = min(res_crop(:)); 
    [rMin,cMin] = ind2sub(size(res_crop),minidx);
    % convert to original image coordinates
    ymin = yxmin(1) + rMin - cropsize/2 - 1;
    xmin = yxmin(2) + cMin - cropsize/2 - 1;
    xmin = min([xmin,size(im,2) - cropsize,wrong_corepoint(1)]);
    ymin = min([ymin,size(im,1) - cropsize,wrong_corepoint(2)]);
    xmin = max([xmin,1,wrong_corepoint(1) - cropsize + 1]);
    ymin = max([ymin,1,wrong_corepoint(2) - cropsize + 1]);
    rect = [xmin ymin cropsize cropsize];
    % plot
    figure;
    imshow(im);
    hold on
    plot(wrong_corepoint(1),wrong_corepoint(2),'xr','MarkerSize',20,'LineWidth',2);
    rectangle('Position',rect,'LineWidth',2,'EdgeColor','g');
    

    wrong core-point is marked with red X, and cropping rectangle with green:

    enter image description here