1 /*******************************************************************************
2 
3 License:
4 This software was developed at the National Institute of Standards and
5 Technology (NIST) by employees of the Federal Government in the course
6 of their official duties. Pursuant to title 17 Section 105 of the
7 United States Code, this software is not subject to copyright protection
8 and is in the public domain. NIST assumes no responsibility  whatsoever for
9 its use by other parties, and makes no guarantees, expressed or implied,
10 about its quality, reliability, or any other characteristic.
11 
12 Disclaimer:
13 This software was developed to promote biometric standards and biometric
14 technology testing for the Federal Government in accordance with the USA
15 PATRIOT Act and the Enhanced Border Security and Visa Entry Reform Act.
16 Specific hardware and software products identified in this software were used
17 in order to perform the software development.  In no case does such
18 identification imply recommendation or endorsement by the National Institute
19 of Standards and Technology, nor does it imply that the products and equipment
20 identified are necessarily the best available for the purpose.
21 
22 *******************************************************************************/
23 
24 /***********************************************************************
25       LIBRARY: LFS - NIST Latent Fingerprint System
26 
27       FILE:    GLOBALS.C
28       AUTHOR:  Michael D. Garris
29       DATE:    03/16/1999
30       UPDATED: 10/04/1999 Version 2 by MDG
31 
32       Contains general global variable definitions required by the
33       NIST Latent Fingerprint System (LFS).
34 ***********************************************************************/
35 
36 #include <lfs.h>
37 
38 /*************************************************************************/
39 /*        GOBAL DECLARATIONS                                             */
40 /*************************************************************************/
41 
42 #ifdef LOG_REPORT
43 FILE *g_logfp;
44 #endif
45 
46 /* Constants (C) for defining 4 DFT frequencies, where  */
47 /* frequency is defined as C*(PI_FACTOR).  PI_FACTOR    */
48 /* regulates the period of the function in x, so:       */
49 /*      1 = one period in range X.                      */
50 /*      2 = twice the frequency in range X.             */
51 /*      3 = three times the frequency in reange X.      */
52 /*      4 = four times the frequency in ranage X.       */
53 double g_dft_coefs[NUM_DFT_WAVES] = { 1,2,3,4 };
54 
55 /* Allocate and initialize a global LFS parameters structure. */
56 LFSPARMS g_lfsparms = {
57    /* Image Controls */
58    PAD_VALUE,
59    JOIN_LINE_RADIUS,
60 
61    /* Map Controls */
62    IMAP_BLOCKSIZE,
63    UNUSED_INT,           /* windowsize */
64    UNUSED_INT,           /* windowoffset */
65    NUM_DIRECTIONS,
66    START_DIR_ANGLE,
67    RMV_VALID_NBR_MIN,
68    DIR_STRENGTH_MIN,
69    DIR_DISTANCE_MAX,
70    SMTH_VALID_NBR_MIN,
71    VORT_VALID_NBR_MIN,
72    HIGHCURV_VORTICITY_MIN,
73    HIGHCURV_CURVATURE_MIN,
74    UNUSED_INT,           /* min_interpolate_nbrs */
75    UNUSED_INT,           /* percentile_min_max   */
76    UNUSED_INT,           /* min_contrast_delta   */
77 
78    /* DFT Controls */
79    NUM_DFT_WAVES,
80    POWMAX_MIN,
81    POWNORM_MIN,
82    POWMAX_MAX,
83    FORK_INTERVAL,
84    FORK_PCT_POWMAX,
85    FORK_PCT_POWNORM,
86 
87    /* Binarization Controls */
88    DIRBIN_GRID_W,
89    DIRBIN_GRID_H,
90    ISOBIN_GRID_DIM,
91    NUM_FILL_HOLES,
92 
93    /* Minutiae Detection Controls */
94    MAX_MINUTIA_DELTA,
95    MAX_HIGH_CURVE_THETA,
96    HIGH_CURVE_HALF_CONTOUR,
97    MIN_LOOP_LEN,
98    MIN_LOOP_ASPECT_DIST,
99    MIN_LOOP_ASPECT_RATIO,
100 
101    /* Minutiae Link Controls */
102    LINK_TABLE_DIM,
103    MAX_LINK_DIST,
104    MIN_THETA_DIST,
105    MAXTRANS,
106    SCORE_THETA_NORM,
107    SCORE_DIST_NORM,
108    SCORE_DIST_WEIGHT,
109    SCORE_NUMERATOR,
110 
111    /* False Minutiae Removal Controls */
112    MAX_RMTEST_DIST,
113    MAX_HOOK_LEN,
114    MAX_HALF_LOOP,
115    TRANS_DIR_PIX,
116    SMALL_LOOP_LEN,
117    SIDE_HALF_CONTOUR,
118    INV_BLOCK_MARGIN,
119    RM_VALID_NBR_MIN,
120    UNUSED_INT,         /* max_overlap_dist       */
121    UNUSED_INT,         /* max_overlap_join_dist  */
122    UNUSED_INT,         /* malformation_steps_1   */
123    UNUSED_INT,         /* malformation_steps_2   */
124    UNUSED_DBL,         /* min_malformation_ratio */
125    UNUSED_INT,         /* max_malformation_dist  */
126    PORES_TRANS_R,
127    PORES_PERP_STEPS,
128    PORES_STEPS_FWD,
129    PORES_STEPS_BWD,
130    PORES_MIN_DIST2,
131    PORES_MAX_RATIO,
132    FALSE, /* not removing perimeter points by default */
133    PERIMETER_PTS_DISTANCE,
134 
135    /* Ridge Counting Controls */
136    MAX_NBRS,
137    MAX_RIDGE_STEPS
138 };
139 
140 
141 /* Allocate and initialize VERSION 2 global LFS parameters structure. */
142 LFSPARMS g_lfsparms_V2 = {
143    /* Image Controls */
144    PAD_VALUE,
145    JOIN_LINE_RADIUS,
146 
147    /* Map Controls */
148    MAP_BLOCKSIZE_V2,
149    MAP_WINDOWSIZE_V2,
150    MAP_WINDOWOFFSET_V2,
151    NUM_DIRECTIONS,
152    START_DIR_ANGLE,
153    RMV_VALID_NBR_MIN,
154    DIR_STRENGTH_MIN,
155    DIR_DISTANCE_MAX,
156    SMTH_VALID_NBR_MIN,
157    VORT_VALID_NBR_MIN,
158    HIGHCURV_VORTICITY_MIN,
159    HIGHCURV_CURVATURE_MIN,
160    MIN_INTERPOLATE_NBRS,
161    PERCENTILE_MIN_MAX,
162    MIN_CONTRAST_DELTA,
163 
164    /* DFT Controls */
165    NUM_DFT_WAVES,
166    POWMAX_MIN,
167    POWNORM_MIN,
168    POWMAX_MAX,
169    FORK_INTERVAL,
170    FORK_PCT_POWMAX,
171    FORK_PCT_POWNORM,
172 
173    /* Binarization Controls */
174    DIRBIN_GRID_W,
175    DIRBIN_GRID_H,
176    UNUSED_INT,          /* isobin_grid_dim */
177    NUM_FILL_HOLES,
178 
179    /* Minutiae Detection Controls */
180    MAX_MINUTIA_DELTA,
181    MAX_HIGH_CURVE_THETA,
182    HIGH_CURVE_HALF_CONTOUR,
183    MIN_LOOP_LEN,
184    MIN_LOOP_ASPECT_DIST,
185    MIN_LOOP_ASPECT_RATIO,
186 
187    /* Minutiae Link Controls */
188    UNUSED_INT,          /* link_table_dim     */
189    UNUSED_INT,          /* max_link_dist      */
190    UNUSED_INT,          /* min_theta_dist     */
191    MAXTRANS,            /* used for removing overlaps as well */
192    UNUSED_DBL,          /* score_theta_norm   */
193    UNUSED_DBL,          /* score_dist_norm    */
194    UNUSED_DBL,          /* score_dist_weight  */
195    UNUSED_DBL,          /* score_numerator    */
196 
197    /* False Minutiae Removal Controls */
198    MAX_RMTEST_DIST_V2,
199    MAX_HOOK_LEN_V2,
200    MAX_HALF_LOOP_V2,
201    TRANS_DIR_PIX_V2,
202    SMALL_LOOP_LEN,
203    SIDE_HALF_CONTOUR,
204    INV_BLOCK_MARGIN_V2,
205    RM_VALID_NBR_MIN,
206    MAX_OVERLAP_DIST,
207    MAX_OVERLAP_JOIN_DIST,
208    MALFORMATION_STEPS_1,
209    MALFORMATION_STEPS_2,
210    MIN_MALFORMATION_RATIO,
211    MAX_MALFORMATION_DIST,
212    PORES_TRANS_R,
213    PORES_PERP_STEPS,
214    PORES_STEPS_FWD,
215    PORES_STEPS_BWD,
216    PORES_MIN_DIST2,
217    PORES_MAX_RATIO,
218    FALSE, /* not removing perimeter points by default */
219    PERIMETER_PTS_DISTANCE,
220 
221    /* Ridge Counting Controls */
222    MAX_NBRS,
223    MAX_RIDGE_STEPS
224 };
225 
226 /* Variables for conducting 8-connected neighbor analyses. */
227 /* Pixel neighbor offsets:  0  1  2  3  4  5  6  7  */     /* 7 0 1 */
228 int g_nbr8_dx[] =          {  0, 1, 1, 1, 0,-1,-1,-1 };      /* 6 C 2 */
229 int g_nbr8_dy[] =          { -1,-1, 0, 1, 1, 1, 0,-1 };      /* 5 4 3 */
230 
231 /* The chain code lookup matrix for 8-connected neighbors. */
232 /* Should put this in globals.                             */
233 int g_chaincodes_nbr8[]={ 3, 2, 1,
234                         4,-1, 0,
235                         5, 6, 7};
236 
237 /* Global array of feature pixel pairs. */
238 FEATURE_PATTERN g_feature_patterns[]=
239                        {{RIDGE_ENDING,  /* a. Ridge Ending (appearing) */
240                          APPEARING,
241                          {0,0},
242                          {0,1},
243                          {0,0}},
244 
245                         {RIDGE_ENDING,  /* b. Ridge Ending (disappearing) */
246                          DISAPPEARING,
247                          {0,0},
248                          {1,0},
249                          {0,0}},
250 
251                         {BIFURCATION,   /* c. Bifurcation (disappearing) */
252                          DISAPPEARING,
253                          {1,1},
254                          {0,1},
255                          {1,1}},
256 
257                         {BIFURCATION,   /* d. Bifurcation (appearing) */
258                          APPEARING,
259                          {1,1},
260                          {1,0},
261                          {1,1}},
262 
263                         {BIFURCATION,   /* e. Bifurcation (disappearing) */
264                          DISAPPEARING,
265                          {1,0},
266                          {0,1},
267                          {1,1}},
268 
269                         {BIFURCATION,   /* f. Bifurcation (disappearing) */
270                          DISAPPEARING,
271                          {1,1},
272                          {0,1},
273                          {1,0}},
274 
275                         {BIFURCATION,   /* g. Bifurcation (appearing) */
276                          APPEARING,
277                          {1,1},
278                          {1,0},
279                          {0,1}},
280 
281                         {BIFURCATION,   /* h. Bifurcation (appearing) */
282                          APPEARING,
283                          {0,1},
284                          {1,0},
285                          {1,1}},
286 
287                         {BIFURCATION,   /* i. Bifurcation (disappearing) */
288                          DISAPPEARING,
289                          {1,0},
290                          {0,1},
291                          {1,0}},
292 
293                         {BIFURCATION,   /* j. Bifurcation (appearing) */
294                          APPEARING,
295                          {0,1},
296                          {1,0},
297                          {0,1}}};
298