数字图像处理Project1——指纹图片的增强

要求

这里写图片描述
这里写图片描述
去掉给定指纹区域附近的雾气。

方法

1, Make a histogram of the origin picture, observe the gray distribution of the pixel.
2, Choose the appropriate threshold and then turn the picture into binarization.
3, Define a mask matrix and turn the black pixel into white and turn the white pixel into black, so that we can use the erosion and dilation easily.
4, Use the method of morphology such as erosion and dilation, as well as Open and Close operation, to obtain a basic area of the finger image without the noises, which are around the finger.
5, After obtain the area of finger, turn this area into the origin picture by multiply the input picture.
6, Choose the part of the picture which been smoothing slightly to fulfill the result picture, where lost some detail after masking.
7, Turn the result picture into binarization to have a better look of the result.

效果

这里写图片描述
这里写图片描述
8
8R
18
18R
22
这里写图片描述

源码(Matlab)

%picture 5
clear all;
x =  imread('5.bmp');
[M,N]=size(x);
x_5 = x;

g = im2bw(x,80/255);

mask=zeros(M,N);
g =uint8(g);
for i=1:M
    for j=1:N
       if(g(i,j)==0)
          mask(i,j)=1;
       end  
    end
end

B1 = ones(6);
B2 = ones(3);

f1 = imdilate(mask,B2);
f1=imerode(f1,B2);

f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);


f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);

for i =1:11
    f1=imdilate(f1,B1);
end

for i =1:13
    f1=imerode(f1,B1);
end

g =x.*uint8(f1);
for i=1:M
    for j=1:N
     if(g(i,j)==0)
          g(i,j)=255; 
     end
   end
end

g_5 = im2bw(g,220/255);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%picture 8
x =  imread('8.bmp');
[M,N]=size(x);
x_8 = x;

g = im2bw(x,80/255);

mask=zeros(M,N);
g =uint8(g);
for i=1:M
    for j=1:N
       if(g(i,j)==0)
          mask(i,j)=1;
       end  
    end
end

B1 = ones(6);
B2 = ones(3);

f1 = imdilate(mask,B2);
f1=imerode(f1,B2);

f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);


f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);


for i =1:8
    f1=imdilate(f1,B1);
end

for i =1:11
    f1=imerode(f1,B1);
end

g =x.*uint8(f1);
for i=1:M
    for j=1:N
     if(g(i,j)==0)
          g(i,j)=255; 
     end
   end
end

g_8 = im2bw(g,240/255);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%picture 18

x =  imread('18.bmp');
[M,N]=size(x);
x_18 = x;
g_orign = x;

t = 190;
for i=1:M
    for j=1:N
        if (g_orign(i,j)>=t)
            g_orign(i,j)=255;
        else
            g_orign(i,j)=0;
        end
    end
end

g = im2bw(x,100/255);

mask=zeros(M,N);
g =uint8(g);
for i=1:M
    for j=1:N
       if(g(i,j)==0)
          mask(i,j)=1;
       end  
    end
end

B1 = ones(6);
B2 = ones(3);

f1 = imdilate(mask,B2);
f1=imerode(f1,B2);

f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);


f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);


for i =1:19
    f1=imdilate(f1,B1);
end

for i =1:13
    f1=imerode(f1,B1);
end


g =x.*uint8(f1);
for i=1:M
    for j=1:N
     if(g(i,j)==0)
          g(i,j)=255; 
     end
   end
end

for i=2*M/3:M
    for j=1:N
      g(i,j) = g_orign(i,j);
   end
end

g_18 = im2bw(g,220/255);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%picture 22

x_rgb =  imread('22.jpg');
x = rgb2gray(x_rgb);
[M,N]=size(x);
x_22 = x;
x_orign = x;

g = im2bw(x,35/255);

mask=zeros(M,N);
g =uint8(g);
for i=1:M
    for j=1:N
       if(g(i,j)==0)
          mask(i,j)=1;
       end  
    end
end

B1 = ones(9);
B2 = ones(3);

f1 = imdilate(mask,B2);
f1=imerode(f1,B2);

f1=imdilate(f1,B1);
f1=imdilate(f1,B1);
f1=imdilate(f1,B1);

f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);
f1=imerode(f1,B1);

for i =1:13
    f1=imdilate(f1,B1);
end

for i =1:13
    f1=imerode(f1,B1);
end

g =x.*uint8(f1);
for i=1:M
    for j=1:N
     if(g(i,j)==0)
          g(i,j)=255;         
     end
   end
end

for i=M/2:M
    for j=1:N
      g(i,j) = x_orign(i,j);
   end
end

SE = [0 1 0;
      1 1 1;
      0 1 0;];
g_22 = imerode(g,SE);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%output the result
figure(1)
subplot(2,4,1)
imshow(x_5),title('Orign5');
subplot(2,4,2);
imshow(g_5),title('Result5');
subplot(2,4,3)
imshow(x_8),title('Orign8');
subplot(2,4,4);
imshow(g_8),title('Result8');

subplot(2,4,5)
imshow(x_18),title('Orign18');
subplot(2,4,6);
imshow(g_18),title('Result18');
subplot(2,4,7)
imshow(x_22),title('Orign22');
subplot(2,4,8);
imshow(g_22),title('Result22');
指纹增强-指纹增强.rar 有一位论坛朋友寻找的关于一篇经典指纹增强文章的源代码: 帖子如下(含文章): https://www.ilovematlab.cn/thread-74316-1-1.html 这个源程序的一个实例:介绍一下怎么应用 clear clc im = imread; if length)>2     im=rgb2gray; end         % Identify ridge-like regions and normalise image     blksze = 16; thresh = 0.1;     [normim, mask] = ridgesegment;     show;     % Determine ridge orientations     [orientim, reliability] = ridgeorient;     plotridgeorient     show 1.jpg 2.jpg 3.jpg                            原图                                                                    Orientations overlaid                                        'Reliability' of orientations                                   % Determine ridge frequency values across the image     blksze = 36;     [freq, medfreq] = ridgefreq;     show                                 Frequency data          % Actually I find the median frequency value used across the whole    % fingerprint gives a more satisfactory result...       freq = medfreq.*mask;         % Now apply filters to enhance the ridge pattern    newim = ridgefilter;    show;                                 Filtered image             % Binarise, ridge/valley threshold is 0    binim = newim > 0;    show;                                 Binary image         % Display binary image for where the mask values are one and where    % the orientation reliability is greater than 0.5    show, 7)                                 Masked binary image                                 Original image 程序包如下: 指纹增强.rar 程序包含: QQ截图未命名.jpg
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值