使用matlab中的交叉数进行细节点提取

时间:2018-01-19 06:38:08

标签: matlab fingerprint

我正在研究指纹识别中的细节点(结束和分叉)提取,我正在使用交叉编号。我在Matlab中应用了以下代码。在这段代码中,我将颜色代码应用于结束和分叉,以便我们可以在二进制图像中轻松地看到这些点。

CN正在寻找交叉号码。我正在使用一个3 * 3的图像窗口,只找到3 * 3图像补丁中心值为1的补丁的交叉号。

但我发现它提取了错误的结束点。此外,使用此代码也无法检测到所有分叉。有人可以建议任何更改或帮助我找出代码中的错误。

Matlab代码: -

binary_image=im2bw(imread('input_1.tif'));
%% Skeleton
skel_image=~bwmorph(binary_image,'skel',Inf);
% figure;imtool(skel_image);title('Skeleton Image');

inv_skel_image = 1-skel_image;
figure;imtool(inv_skel_image);title('Inverse Skeleton Image');

test_inv_img = inv_skel_image;

%% crossing number
[r, c]=size(test_inv_img);

CN_Count = zeros(r,c);
CI = zeros(r, c, 3);
e = 1;
CN_4 = 0;
for i=2:r-1
    for j=2:c-1

        Sub_Image = test_inv_img(i-1:i+1,j-1:j+1);

        if(Sub_Image(2,2) == 1)
            CN_Count(i,j) = sum(Sub_Image(:));
            CN = CN_Count(i,j);
            if CN == 1  % Isolated
                CI(i, j, 1) = 255; % white
                CI(i, j, 2) = 255;
                CI(i, j, 3) = 255;
            end
            if CN == 2  % Ending
                % find co-ordinates of ending
                Ending(e,1) = i;
                Ending(e,2) = j;
                e = e+1;
                CI(i, j, 2) = 255; % GREEN
            end
            if CN == 3  % Continue
                CI(i, j, 3) = 255; % BLUE

            end
            if CN == 4 % Bifurcation
                if((Sub_Image(2,1)==1) && (Sub_Image(1,3)==1) && (Sub_Image(3,3)==1))
                    CI(i, j, 1) = 255; %RED
                elseif((Sub_Image(1,2)==1) && (Sub_Image(3,1)==1) && (Sub_Image(3,3)==1))

                    CI(i, j, 1) = 255; %RED
                elseif((Sub_Image(1,1)==1) && (Sub_Image(1,3)==1) && (Sub_Image(2,3)==1))
                    CI(i, j, 1) = 255; %RED
                elseif((Sub_Image(1,1)==1) && (Sub_Image(1,3)==1) && (Sub_Image(3,2)==1))
                    CI(i, j, 1) = 255; %RED
                else
                    CN_4 = CN_4 + 1;
                end
            end

            if CN == 5 % CROSSING
                CI(i, j, 1) = 255; %pink
                CI(i, j, 2) = 255;
                CI(i, j, 3) = 0;
            end

        end
    end
end
imtool(CI, []);

%% to find coordinates using color codes
% All 3 planes values
R_Plane=CI(:,:,1);
G_Plane=CI(:,:,2);
B_Plane=CI(:,:,3);

% [j1,j2]=find(Mask_End);

% find co-ordinates of Ending using color codes
Mask_End = (R_Plane==0) & (G_Plane==255) & (B_Plane==0);
[Ending1(:,1),Ending1(:,2)]=find(Mask_End);

% find co-ordinates of Bifurcation using color codes
Mask_Bif = (R_Plane==255) & (G_Plane==0) & (B_Plane==0);
[Bif1(:,1),Bif1(:,2)]=find(Mask_Bif);

0 个答案:

没有答案