function fpextractdemo(action, varargin)
% FPEXTRACTDEMO Fingerprint extracting the features on DEMO API program
% Cheng Long Adam Wang, September 2002
%
% $Revision: 1.0 $ $Date: 2002.10.2 $
% $Revision: 2.0 $ $Date: 2003.11.29 $ by Luigi Rosa
% email: luigi.rosa@tiscali.it
% mobile: +393403463208
% website: http://utenti.lycos.it/matlab
%
% Modified:
% - new GUI
% - 8 Gabor filters 0 22.5 45 67.5 90 112.5 135 157.5 degree
% - Convolution is performed in frequency domain
% - DataBase
% - Fingerprint matching
% - Error management
%
% Input fingerprint should be 256 x 256 grayscale bmp image
% 8-bit grayscale image @ 500 dpi.
% If these conditions are not verified some parameters in m-functions
% should be changed in a proper way.
%
% Options:
% - Centralize: calculate the center point and the binarized image
% - Crop: image cropping
% - Sectorize: visualize the circular sectors
% - Normalize: normalize input image
% - Gabor filters: visualize the Gabor filters
% - Convolute: compute convolution of input image and Gabor filters
% - Features: FingerCodes visualization
% - FingerCode: add the input fingerprint to Database
% - Check: fingerprint matching
%
%
% A crucial step in fingerprint recognition is center point determination.
% If any error occurs while cropping image you can use the auxiliary m-file
% "vedicentro.m": it visualizes the input fingerprint and the center point
% calculated by the m-function "centralizing.m"
%
%
% References
%
% Cheng Long Adam Wang, researcher
% Fingerprint Recognition System
% http://home.kimo.com.tw/carouse9/FRS.htm
%
% A. K. Jain, S. Prabhakar, and S. Pankanti, "A Filterbank-based Representation for
% Classification and Matching of Fingerprints", International Joint Conference on
% Neural Networks (IJCNN), pp. 3284-3285, Washington DC, July 10-16, 1999.
% http://www.cse.msu.edu/~prabhaka/publications.html
%
% "Fingerprint Classification and Matching Using a Filterbank", Salil Prabhakar
% A DISSERTATION Submitted to Michigan State University in partial fulfillment
% of the requirements for the degree of DOCTOR OF PHILOSOPHY, Computer
% Science & Engineering, 2001
% http://biometrics.cse.msu.edu/SalilThesis.pdf
%
% Final Report 18-551 (Spring 1999) Fingerprint Recognition Group Number 19
% Markus Adhiwiyogo, Samuel Chong, Joseph Huang, Weechoon Teo
% http://www.ece.cmu.edu/~ee551/Old_projects/projects/s99_19/finalreport.html
%
% Type "fpextractdemo" on MATLAB prompt to start fingerprint processing.
%
%--------------------------------------------------------------------------
if nargin<1,
action='InitializeFPEXTRACTDEMO';
end;
feval(action,varargin{:})
return;
%%%
%%% Sub-function - InitializeFPEXTRACTDEMO
%%%
function InitializeFPEXTRACTDEMO()
% If fpextractdemo is already running, bring it to the foreground
h = findobj(allchild(0), 'tag', 'Extracting FingerPrint Features Demo');
if ~isempty(h)
figure(h(1))
return
end
screenD = get(0, 'ScreenDepth');
if screenD>8
grayres=256;
else
grayres=128;
end
FpextractDemoFig = figure( ...
'Name','Extracting FingerPrint Features Demo', ...
'NumberTitle','off', 'HandleVisibility', 'on', ...
'tag', 'Extracting FingerPrint Features Demo', ...
'Visible','off', 'Resize', 'off',...
'BusyAction','Queue','Interruptible','off', ...
'Color', [.8 .8 .8], ...
'IntegerHandle', 'off', ...
'Colormap', gray(grayres));
figpos = get(FpextractDemoFig, 'position');
figpos(3:4) = [1050 525];
% Adjust the size of the figure window
horizDecorations = 10; % resize controls, etc.
vertDecorations = 45; % title bar, etc.
screenSize = get(0,'ScreenSize');
dx = screenSize(3) - figpos(1) - figpos(3) - horizDecorations;
dy = screenSize(4) - figpos(2) - figpos(4) - vertDecorations;
if (dx < 0)
figpos(1) = max(5,figpos(1) + dx);
end
if (dy < 0)
figpos(2) = max(5,figpos(2) + dy);
end
set(FpextractDemoFig, 'position', figpos);
rows = figpos(4);
cols = figpos(3);
% Colors
bgcolor = [0.45 0.45 0.45]; % Background color for frames
wdcolor = [.8 .8 .8]; % Window color
fgcolor = [1 1 1]; % For text
hs = (cols-(6*175)) / 5; % Horizantal Spacing
vs = (rows)/8; % Vertical Spacing
%====================================
% Parameters for all buttons and menus
Std.Interruptible = 'off';
Std.BusyAction = 'queue';
% Defaults for image axes
Ax = Std;
Ax.Units = 'Pixels';
Ax.Parent = FpextractDemoFig;
Ax.ydir = 'reverse';
Ax.XLim = [.5 128.5];
Ax.YLim = [.5 128.5];
Ax.CLim = [0 1];
Ax.XTick = [];
Ax.YTick = [];
Img = Std;
Img.CData = [];
Img.Xdata = [1 128];
Img.Ydata = [1 128];
Img.CDataMapping = 'Scaled';
Img.Erasemode = 'none';
Ctl = Std;
Ctl.Units = 'Pixels';
Ctl.Parent = FpextractDemoFig;
Btn = Ctl;
Btn.Style = 'pushbutton';
Btn.Enable = 'off';
Edit = Ctl;
Edit.Style = 'edit';
Edit.HorizontalAlignment = 'right';
Edit.BackgroundColor = 'white';
Edit.ForegroundColor = 'black';
Menu = Ctl;
Menu.Style = 'Popupmenu';
Text = Ctl;
Text.Style = 'text';
Text.HorizontalAlignment = 'left';
Text.BackgroundColor = bgcolor;
Text.ForegroundColor = fgcolor;
%================================
% 0 degree Component
ud.hComponent1Axes = axes(Ax, ...
'Position', [0*vs/6 5*vs-vs/6 175 175]);
title('0 degree Component');
ud.hComponent1Image = image(Img, ...
'Parent', ud.hComponent1Axes);
%================================
% Original FingerPrint
ud.hOriginalAxes = axes(Ax, ...
'Position', [cols/2-128 5*vs-vs/6-81 256 256]);
title('Original FingerPrint');
ud.hOriginalImage = image(Img, ...
'Parent', ud.hOriginalAxes);
ud.OriginalImageIsStale = 1;
%================================
% 157.5 degree Component
ud.hComponent8Axes = axes(Ax, ...
'Position', [cols-175 5*vs-vs/6 175 175]);
title('157.5 degree Component');
ud.hComponent8Image = image(Img, ...
'Parent', ud.hComponent8Axes);
%=================================
% 22.5 degree Component
ud.hComponent2Axes = axes(Ax, ...
'Position', [hs vs/2 175 175]);
title('22.5 degree Component');
ud.hComponent2Image = image(Img, ...
'Parent', ud.hComponent2Axes);
%================================
% 45 degree Component
ud.hComponent3Axes = axes(Ax, ...
'Position', [2*hs+1*175 vs/2 175 175]);
title('45 degree Component');
ud.hComponent3Image = image(Img, ...
'Parent', ud.hComponent3Axes);
%================================
% 67.5 degree Component
ud.hComponent4Axes = axes(Ax, ...
'Position', [3*hs+2*175 vs/2 175 175]);
title('67.5 degree Component');
ud.hComponent4Image = image(Img, ...
'Parent', ud.hComponent4Axes);
%=================================
% 90 degree Component
ud.hComponent5Axes = axes(Ax, ...
'Position', [4*hs+3*175 vs/2 175 175]);
title('90 degree Component');
ud.hComponent5Image = image(Img, ...
'Parent', ud.hComponent5Axes);
%=================================
% 112.5 degree Component
ud.hComponent6Axes = axes(Ax, ...
'Position', [5*hs+4*175 vs/2 175 175]);
title('112.5 degree Component');
ud.hComponent6Image = image(Img, ...
'Parent', ud.hComponent6Axes);
%=================================
% 135 degree Component
ud.hComponent7Axes = axes(Ax, ...
'Position', [6*hs+5*175 vs/2 175 175]);
title('135 degree Component');
ud.hComponent7Image = image(Img, ...
'Parent', ud.hComponent7Axes);
%=================================
% The frame
ud.hControlFrame = uicontrol(Std, ...
'Parent', FpextractDemoFig, ...
'Style', 'Frame', ...
'Units', 'pixels', ...
'Position', [vs/6 5*vs-vs/