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 #ifndef _LFS_H 25 #define _LFS_H 26 27 /*********************************************************************** 28 PACKAGE: NIST Latent Fingerprint System 29 AUTHOR: Michael D. Garris 30 DATE: 03/16/1999 31 UPDATED: 10/04/1999 Version 2 by MDG 32 UPDATED: 10/26/1999 by MDG 33 Comments added to guide changes to blocksize 34 or number of detected directions. 35 UPDATED: 03/11/2005 by MDG 36 37 FILE: LFS.H 38 39 Contains all custom structure definitions, constant definitions, 40 external function definitions, and external global variable 41 definitions required by the NIST Latent Fingerprint System (LFS). 42 ***********************************************************************/ 43 44 #include <math.h> 45 #include <stdio.h> 46 #include <fp_internal.h> 47 48 /*************************************************************************/ 49 /* OUTPUT FILE EXTENSIONS */ 50 /*************************************************************************/ 51 #define MIN_TXT_EXT "min" 52 #define LOW_CONTRAST_MAP_EXT "lcm" 53 #define HIGH_CURVE_MAP_EXT "hcm" 54 #define DIRECTION_MAP_EXT "dm" 55 #define LOW_FLOW_MAP_EXT "lfm" 56 #define QUALITY_MAP_EXT "qm" 57 #define AN2K_OUT_EXT "mdt" 58 #define BINARY_IMG_EXT "brw" 59 #define XYT_EXT "xyt" 60 61 /*************************************************************************/ 62 /* MINUTIAE XYT REPRESENTATION SCHEMES */ 63 /*************************************************************************/ 64 #define NIST_INTERNAL_XYT_REP 0 65 #define M1_XYT_REP 1 66 67 /*************************************************************************/ 68 /* MACRO DEFINITIONS */ 69 /*************************************************************************/ 70 71 #define max(a, b) ((a) > (b) ? (a) : (b)) 72 #define min(a, b) ((a) < (b) ? (a) : (b)) 73 #define sround(x) ((int) (((x)<0) ? (x)-0.5 : (x)+0.5)) 74 #define trunc_dbl_precision(x, scale) ((double) (((x)<0.0) \ 75 ? ((int)(((x)*(scale))-0.5))/(scale) \ 76 : ((int)(((x)*(scale))+0.5))/(scale))) 77 78 #ifndef M_PI 79 #define M_PI 3.14159265358979323846 /* pi */ 80 #endif 81 82 /*************************************************************************/ 83 /* STRUCTURE DEFINITIONS */ 84 /*************************************************************************/ 85 86 /* Lookup tables for converting from integer directions */ 87 /* to angles in radians. */ 88 typedef struct dir2rad{ 89 int ndirs; 90 double *cos; 91 double *sin; 92 } DIR2RAD; 93 94 /* DFT wave form structure containing both cosine and */ 95 /* sine components for a specific frequency. */ 96 typedef struct dftwave{ 97 double *cos; 98 double *sin; 99 } DFTWAVE; 100 101 /* DFT wave forms structure containing all wave forms */ 102 /* to be used in DFT analysis. */ 103 typedef struct dftwaves{ 104 int nwaves; 105 int wavelen; 106 DFTWAVE **waves; 107 }DFTWAVES; 108 109 /* Rotated pixel offsets for a grid of specified dimensions */ 110 /* rotated at a specified number of different orientations */ 111 /* (directions). This structure used by the DFT analysis */ 112 /* when generating a Direction Map and also for conducting */ 113 /* isotropic binarization. */ 114 typedef struct rotgrids{ 115 int pad; 116 int relative2; 117 double start_angle; 118 int ngrids; 119 int grid_w; 120 int grid_h; 121 int **grids; 122 } ROTGRIDS; 123 124 /*************************************************************************/ 125 /* 10, 2X3 pixel pair feature patterns used to define ridge endings */ 126 /* and bifurcations. */ 127 /* 2nd pixel pair is permitted to repeat multiple times in match. */ 128 #define NFEATURES 10 129 #define BIFURCATION 0 130 #define RIDGE_ENDING 1 131 #define DISAPPEARING 0 132 #define APPEARING 1 133 134 typedef struct fp_minutia MINUTIA; 135 typedef struct fp_minutiae MINUTIAE; 136 137 typedef struct feature_pattern{ 138 int type; 139 int appearing; 140 int first[2]; 141 int second[2]; 142 int third[2]; 143 } FEATURE_PATTERN; 144 145 /* SHAPE structure definitions. */ 146 typedef struct rows{ 147 int y; /* Y-coord of current row in shape. */ 148 int *xs; /* X-coords for shape contour points on current row. */ 149 int alloc; /* Number of points allocate for x-coords on row. */ 150 int npts; /* Number of points assigned for x-coords on row. */ 151 } ROW; 152 153 typedef struct shape{ 154 int ymin; /* Y-coord of top-most scanline in shape. */ 155 int ymax; /* Y-coord of bottom-most scanline in shape. */ 156 ROW **rows; /* List of row pointers comprising the shape. */ 157 int alloc; /* Number of rows allocated for shape. */ 158 int nrows; /* Number of rows assigned to shape. */ 159 } SHAPE; 160 161 /* Parameters used by LFS for setting thresholds and */ 162 /* defining testing criterion. */ 163 typedef struct lfsparms{ 164 /* Image Controls */ 165 int pad_value; 166 int join_line_radius; 167 168 /* Map Controls */ 169 int blocksize; /* Pixel dimension image block. */ 170 int windowsize; /* Pixel dimension window surrounding block. */ 171 int windowoffset; /* Offset in X & Y from block to window origin. */ 172 int num_directions; 173 double start_dir_angle; 174 int rmv_valid_nbr_min; 175 double dir_strength_min; 176 int dir_distance_max; 177 int smth_valid_nbr_min; 178 int vort_valid_nbr_min; 179 int highcurv_vorticity_min; 180 int highcurv_curvature_min; 181 int min_interpolate_nbrs; 182 int percentile_min_max; 183 int min_contrast_delta; 184 185 /* DFT Controls */ 186 int num_dft_waves; 187 double powmax_min; 188 double pownorm_min; 189 double powmax_max; 190 int fork_interval; 191 double fork_pct_powmax; 192 double fork_pct_pownorm; 193 194 /* Binarization Controls */ 195 int dirbin_grid_w; 196 int dirbin_grid_h; 197 int isobin_grid_dim; 198 int num_fill_holes; 199 200 /* Minutiae Detection Controls */ 201 int max_minutia_delta; 202 double max_high_curve_theta; 203 int high_curve_half_contour; 204 int min_loop_len; 205 double min_loop_aspect_dist; 206 double min_loop_aspect_ratio; 207 208 /* Minutiae Link Controls */ 209 int link_table_dim; 210 int max_link_dist; 211 int min_theta_dist; 212 int maxtrans; 213 double score_theta_norm; 214 double score_dist_norm; 215 double score_dist_weight; 216 double score_numerator; 217 218 /* False Minutiae Removal Controls */ 219 int max_rmtest_dist; 220 int max_hook_len; 221 int max_half_loop; 222 int trans_dir_pix; 223 int small_loop_len; 224 int side_half_contour; 225 int inv_block_margin; 226 int rm_valid_nbr_min; 227 int max_overlap_dist; 228 int max_overlap_join_dist; 229 int malformation_steps_1; 230 int malformation_steps_2; 231 double min_malformation_ratio; 232 int max_malformation_dist; 233 int pores_trans_r; 234 int pores_perp_steps; 235 int pores_steps_fwd; 236 int pores_steps_bwd; 237 double pores_min_dist2; 238 double pores_max_ratio; 239 int remove_perimeter_pts; 240 int min_pp_distance; 241 242 /* Ridge Counting Controls */ 243 int max_nbrs; 244 int max_ridge_steps; 245 } LFSPARMS; 246 247 /*************************************************************************/ 248 /* LFS CONSTANT DEFINITIONS */ 249 /*************************************************************************/ 250 251 /***** IMAGE CONSTANTS *****/ 252 253 #ifndef DEFAULT_PPI 254 #define DEFAULT_PPI 500 255 #endif 256 257 /* Intensity used to fill padded image area */ 258 #define PAD_VALUE 128 /* medium gray @ 8 bits */ 259 260 /* Intensity used to draw on grayscale images */ 261 #define DRAW_PIXEL 255 /* white in 8 bits */ 262 263 /* Definitions for 8-bit binary pixel intensities. */ 264 #define WHITE_PIXEL 255 265 #define BLACK_PIXEL 0 266 267 /* Definitions for controlling join_miutia(). */ 268 /* Draw without opposite perimeter pixels. */ 269 #define NO_BOUNDARY 0 270 271 /* Draw with opposite perimeter pixels. */ 272 #define WITH_BOUNDARY 1 273 274 /* Radial width added to join line (not including the boundary pixels). */ 275 #define JOIN_LINE_RADIUS 1 276 277 278 /***** MAP CONSTANTS *****/ 279 280 /* Map value for not well-defined directions */ 281 #define INVALID_DIR -1 282 283 /* Map value assigned when the current block has no neighbors */ 284 /* with valid direction. */ 285 #define NO_VALID_NBRS -3 286 287 /* Map value designating a block is near a high-curvature */ 288 /* area such as a core or delta. */ 289 #define HIGH_CURVATURE -2 290 291 /* This specifies the pixel dimensions of each block in the IMAP */ 292 #define IMAP_BLOCKSIZE 24 293 294 /* Pixel dimension of image blocks. The following three constants work */ 295 /* together to define a system of 8X8 adjacent and non-overlapping */ 296 /* blocks that are assigned results from analyzing a larger 24X24 */ 297 /* window centered about each of the 8X8 blocks. */ 298 /* CAUTION: If MAP_BLOCKSIZE_V2 is changed, then the following will */ 299 /* likely need to be changed: MAP_WINDOWOFFSET_V2, */ 300 /* TRANS_DIR_PIX_V2, */ 301 /* INV_BLOCK_MARGIN_V2 */ 302 #define MAP_BLOCKSIZE_V2 8 303 304 /* Pixel dimension of window that surrounds the block. The result from */ 305 /* analyzing the content of the window is stored in the interior block. */ 306 #define MAP_WINDOWSIZE_V2 24 307 308 /* Pixel offset in X & Y from the origin of the block to the origin of */ 309 /* the surrounding window. */ 310 #define MAP_WINDOWOFFSET_V2 8 311 312 /* This is the number of integer directions to be used in semicircle. */ 313 /* CAUTION: If NUM_DIRECTIONS is changed, then the following will */ 314 /* likely need to be changed: HIGHCURV_VORTICITY_MIN, */ 315 /* HIGHCURV_CURVATURE_MIN, */ 316 /* FORK_INTERVAL */ 317 #define NUM_DIRECTIONS 16 318 319 /* This is the theta from which integer directions */ 320 /* are to begin. */ 321 #define START_DIR_ANGLE (double)(M_PI/2.0) /* 90 degrees */ 322 323 /* Minimum number of valid neighbors required for a */ 324 /* valid block value to keep from being removed. */ 325 #define RMV_VALID_NBR_MIN 3 326 327 /* Minimum strength for a direction to be considered significant. */ 328 #define DIR_STRENGTH_MIN 0.2 329 330 /* Maximum distance allowable between valid block direction */ 331 /* and the average direction of its neighbors before the */ 332 /* direction is removed. */ 333 #define DIR_DISTANCE_MAX 3 334 335 /* Minimum number of valid neighbors required for an */ 336 /* INVALID block direction to receive its direction from */ 337 /* the average of its neighbors. */ 338 #define SMTH_VALID_NBR_MIN 7 339 340 /* Minimum number of valid neighbors required for a block */ 341 /* with an INVALID block direction to be measured for */ 342 /* vorticity. */ 343 #define VORT_VALID_NBR_MIN 7 344 345 /* The minimum vorticity value whereby an INVALID block */ 346 /* is determined to be high-curvature based on the directions */ 347 /* of it neighbors. */ 348 #define HIGHCURV_VORTICITY_MIN 5 349 350 /* The minimum curvature value whereby a VALID direction block is */ 351 /* determined to be high-curvature based on it value compared with */ 352 /* its neighbors' directions. */ 353 #define HIGHCURV_CURVATURE_MIN 5 354 355 /* Minimum number of neighbors with VALID direction for an INVALID */ 356 /* directon block to have its direction interpolated from those neighbors. */ 357 #define MIN_INTERPOLATE_NBRS 2 358 359 /* Definitions for creating a low contrast map. */ 360 /* Percentile cut off for choosing min and max pixel intensities */ 361 /* in a block. */ 362 #define PERCENTILE_MIN_MAX 10 363 364 /* The minimum delta between min and max percentile pixel intensities */ 365 /* in block for block NOT to be considered low contrast. (Note that */ 366 /* this value is in terms of 6-bit pixels.) */ 367 #define MIN_CONTRAST_DELTA 5 368 369 370 /***** DFT CONSTANTS *****/ 371 372 /* This specifies the number of DFT wave forms to be applied */ 373 #define NUM_DFT_WAVES 4 374 375 /* Minimum total DFT power for any given block */ 376 /* which is used to compute an average power. */ 377 /* By setting a non-zero minimum total,possible */ 378 /* division by zero is avoided. This value was */ 379 /* taken from HO39. */ 380 #define MIN_POWER_SUM 10.0 381 382 /* Thresholds and factors used by HO39. Renamed */ 383 /* here to give more meaning. */ 384 /* HO39 Name=Value */ 385 /* Minimum DFT power allowable in any one direction. */ 386 #define POWMAX_MIN 100000.0 /* thrhf=1e5f */ 387 388 /* Minimum normalized power allowable in any one */ 389 /* direction. */ 390 #define POWNORM_MIN 3.8 /* disc=3.8f */ 391 392 /* Maximum power allowable at the lowest frequency */ 393 /* DFT wave. */ 394 #define POWMAX_MAX 50000000.0 /* thrlf=5e7f */ 395 396 /* Check for a fork at +- this number of units from */ 397 /* current integer direction. For example, */ 398 /* 2 dir ==> 11.25 X 2 degrees. */ 399 #define FORK_INTERVAL 2 400 401 /* Minimum DFT power allowable at fork angles is */ 402 /* FORK_PCT_POWMAX X block's max directional power. */ 403 #define FORK_PCT_POWMAX 0.7 404 405 /* Minimum normalized power allowable at fork angles */ 406 /* is FORK_PCT_POWNORM X POWNORM_MIN */ 407 #define FORK_PCT_POWNORM 0.75 408 409 410 /***** BINRAIZATION CONSTANTS *****/ 411 412 /* Directional binarization grid dimensions. */ 413 #define DIRBIN_GRID_W 7 414 #define DIRBIN_GRID_H 9 415 416 /* The pixel dimension (square) of the grid used in isotropic */ 417 /* binarization. */ 418 #define ISOBIN_GRID_DIM 11 419 420 /* Number of passes through the resulting binary image where holes */ 421 /* of pixel length 1 in horizontal and vertical runs are filled. */ 422 #define NUM_FILL_HOLES 3 423 424 425 /***** MINUTIAE DETECTION CONSTANTS *****/ 426 427 /* The maximum pixel translation distance in X or Y within which */ 428 /* two potential minutia points are to be considered similar. */ 429 #define MAX_MINUTIA_DELTA 10 430 431 /* If the angle of a contour exceeds this angle, then it is NOT */ 432 /* to be considered to contain minutiae. */ 433 #define MAX_HIGH_CURVE_THETA (double)(M_PI/3.0) 434 435 /* Half the length in pixels to be extracted for a high-curvature contour. */ 436 #define HIGH_CURVE_HALF_CONTOUR 14 437 438 /* Loop must be larger than this threshold (in pixels) to be considered */ 439 /* to contain minutiae. */ 440 #define MIN_LOOP_LEN 20 441 442 /* If loop's minimum distance half way across its contour is less than */ 443 /* this threshold, then loop is tested for minutiae. */ 444 #define MIN_LOOP_ASPECT_DIST 1.0 445 446 /* If ratio of loop's maximum/minimum distances half way across its */ 447 /* contour is >= to this threshold, then loop is tested for minutiae. */ 448 #define MIN_LOOP_ASPECT_RATIO 2.25 449 450 /* There are 10 unique feature patterns with ID = [0..9] , */ 451 /* so set LOOP ID to 10 (one more than max pattern ID). */ 452 #define LOOP_ID 10 453 454 /* Definitions for controlling the scanning of minutiae. */ 455 #define SCAN_HORIZONTAL 0 456 #define SCAN_VERTICAL 1 457 #define SCAN_CLOCKWISE 0 458 #define SCAN_COUNTER_CLOCKWISE 1 459 460 /* The dimension of the chaincode loopkup matrix. */ 461 #define NBR8_DIM 3 462 463 /* Default minutiae reliability. */ 464 #define DEFAULT_RELIABILITY 0.99 465 466 /* Medium minutia reliability. */ 467 #define MEDIUM_RELIABILITY 0.50 468 469 /* High minutia reliability. */ 470 #define HIGH_RELIABILITY 0.99 471 472 473 /***** MINUTIAE LINKING CONSTANTS *****/ 474 475 /* Definitions for controlling the linking of minutiae. */ 476 /* Square dimensions of 2D table of potentially linked minutiae. */ 477 #define LINK_TABLE_DIM 20 478 479 /* Distance (in pixels) used to determine if the orthogonal distance */ 480 /* between the coordinates of 2 minutia points are sufficiently close */ 481 /* to be considered for linking. */ 482 #define MAX_LINK_DIST 20 483 484 /* Minimum distance (in pixels) between 2 minutia points that an angle */ 485 /* computed between the points may be considered reliable. */ 486 #define MIN_THETA_DIST 5 487 488 /* Maximum number of transitions along a contiguous pixel trajectory */ 489 /* between 2 minutia points for that trajectory to be considered "free" */ 490 /* of obstacles. */ 491 #define MAXTRANS 2 492 493 /* Parameters used to compute a link score between 2 minutiae. */ 494 #define SCORE_THETA_NORM 15.0 495 #define SCORE_DIST_NORM 10.0 496 #define SCORE_DIST_WEIGHT 4.0 497 #define SCORE_NUMERATOR 32000.0 498 499 500 /***** FALSE MINUTIAE REMOVAL CONSTANTS *****/ 501 502 /* Definitions for removing hooks, islands, lakes, and overlaps. */ 503 /* Distance (in pixels) used to determine if the orthogonal distance */ 504 /* between the coordinates of 2 minutia points are sufficiently close */ 505 /* to be considered for removal. */ 506 #define MAX_RMTEST_DIST 8 507 508 #define MAX_RMTEST_DIST_V2 16 509 510 /* Length of pixel contours to be traced and analyzed for possible hooks. */ 511 #define MAX_HOOK_LEN 15 512 513 #define MAX_HOOK_LEN_V2 30 514 515 /* Half the maximum length of pixel contours to be traced and analyzed */ 516 /* for possible loops (islands/lakes). */ 517 #define MAX_HALF_LOOP 15 518 519 #define MAX_HALF_LOOP_V2 30 520 521 /* Definitions for removing minutiae that are sufficiently close and */ 522 /* point to a block with invalid ridge flow. */ 523 /* Distance (in pixels) in direction opposite the minutia to be */ 524 /* considered sufficiently close to an invalid block. */ 525 #define TRANS_DIR_PIX 6 526 527 #define TRANS_DIR_PIX_V2 4 528 529 /* Definitions for removing small holes (islands/lakes). */ 530 /* Maximum circumference (in pixels) of qualifying loops. */ 531 #define SMALL_LOOP_LEN 15 532 533 /* Definitions for removing or adusting side minutiae. */ 534 /* Half the number of pixels to be traced to form a complete contour. */ 535 #define SIDE_HALF_CONTOUR 7 536 537 /* Definitions for removing minutiae near invalid blocks. */ 538 /* Maximum orthogonal distance a minutia can be neighboring a block with */ 539 /* invalid ridge flow in order to be removed. */ 540 #define INV_BLOCK_MARGIN 6 541 542 #define INV_BLOCK_MARGIN_V2 4 543 544 /* Given a sufficiently close, neighboring invalid block, if that invalid */ 545 /* block has a total number of neighboring blocks with valid ridge flow */ 546 /* less than this threshold, then the minutia point is removed. */ 547 #define RM_VALID_NBR_MIN 7 548 549 /* Definitions for removing overlaps. */ 550 /* Maximum pixel distance between 2 points to be tested for overlapping */ 551 /* conditions. */ 552 #define MAX_OVERLAP_DIST 8 553 554 /* Maximum pixel distance between 2 points on opposite sides of an overlap */ 555 /* will be joined. */ 556 #define MAX_OVERLAP_JOIN_DIST 6 557 558 /* Definitions for removing "irregularly-shaped" minutiae. */ 559 /* Contour steps to be traced to 1st measuring point. */ 560 #define MALFORMATION_STEPS_1 10 561 /* Contour steps to be traced to 2nd measuring point. */ 562 #define MALFORMATION_STEPS_2 20 563 /* Minimum ratio of distances across feature at the two point to be */ 564 /* considered normal. */ 565 #define MIN_MALFORMATION_RATIO 2.0 566 /* Maximum distance permitted across feature to be considered normal. */ 567 #define MAX_MALFORMATION_DIST 20 568 569 /* Definitions for removing minutiae on pores. */ 570 /* Translation distance (in pixels) from minutia point in opposite direction */ 571 /* in order to get off a valley edge and into the neighboring ridge. */ 572 #define PORES_TRANS_R 3 573 574 /* Number of steps (in pixels) to search for edge of current ridge. */ 575 #define PORES_PERP_STEPS 12 576 577 /* Number of pixels to be traced to find forward contour points. */ 578 #define PORES_STEPS_FWD 10 579 580 /* Number of pixels to be traced to find backward contour points. */ 581 #define PORES_STEPS_BWD 8 582 583 /* Minimum squared distance between points before being considered zero. */ 584 #define PORES_MIN_DIST2 0.5 585 586 /* Max ratio of computed distances between pairs of forward and backward */ 587 /* contour points to be considered a pore. */ 588 #define PORES_MAX_RATIO 2.25 589 590 /* Points which are closer than this distance to scan perimeter will be removed */ 591 #define PERIMETER_PTS_DISTANCE 10 592 593 594 /***** RIDGE COUNTING CONSTANTS *****/ 595 596 /* Definitions for detecting nearest neighbors and counting ridges. */ 597 /* Maximum number of nearest neighbors per minutia. */ 598 #define MAX_NBRS 5 599 600 /* Maximum number of contour steps taken to validate a ridge crossing. */ 601 #define MAX_RIDGE_STEPS 10 602 603 /*************************************************************************/ 604 /* QUALITY/RELIABILITY DEFINITIONS */ 605 /*************************************************************************/ 606 /* Quality map levels */ 607 #define QMAP_LEVELS 5 608 609 /* Neighborhood radius in millimeters computed from 11 pixles */ 610 /* scanned at 19.69 pixels/mm. */ 611 #define RADIUS_MM ((double)(11.0 / 19.69)) 612 613 /* Ideal Standard Deviation of pixel values in a neighborhood. */ 614 #define IDEALSTDEV 64 615 /* Ideal Mean of pixel values in a neighborhood. */ 616 #define IDEALMEAN 127 617 618 /* Look for neighbors this many blocks away. */ 619 #define NEIGHBOR_DELTA 2 620 621 /*************************************************************************/ 622 /* GENERAL DEFINITIONS */ 623 /*************************************************************************/ 624 #define LFS_VERSION_STR "NIST_LFS_VER2" 625 626 /* This factor converts degrees to radians. */ 627 #ifndef DEG2RAD 628 #define DEG2RAD (double)(M_PI/180.0) 629 #endif 630 631 #define NORTH 0 632 #define SOUTH 4 633 #define EAST 2 634 #define WEST 6 635 636 #ifndef TRUE 637 #define TRUE 1 638 #endif 639 #ifndef FALSE 640 #define FALSE 0 641 #endif 642 643 #ifndef FOUND 644 #define FOUND TRUE 645 #endif 646 #ifndef NOT_FOUND 647 #define NOT_FOUND FALSE 648 #endif 649 650 #define HOOK_FOUND 1 651 #define LOOP_FOUND 1 652 #define IGNORE 2 653 #define LIST_FULL 3 654 #define INCOMPLETE 3 655 656 /* Pixel value limit in 6-bit image. */ 657 #define IMG_6BIT_PIX_LIMIT 64 658 659 /* Maximum number (or reallocated chunks) of minutia to be detected */ 660 /* in an image. */ 661 #define MAX_MINUTIAE 1000 662 663 /* If both deltas in X and Y for a line of specified slope is less than */ 664 /* this threshold, then the angle for the line is set to 0 radians. */ 665 #define MIN_SLOPE_DELTA 0.5 666 667 /* Designates that rotated grid offsets should be relative */ 668 /* to the grid's center. */ 669 #define RELATIVE2CENTER 0 670 671 /* Designates that rotated grid offsets should be relative */ 672 /* to the grid's origin. */ 673 #define RELATIVE2ORIGIN 1 674 675 /* Truncate floating point precision by multiply, rounding, and then */ 676 /* dividing by this value. This enables consistant results across */ 677 /* different computer architectures. */ 678 #define TRUNC_SCALE 16384.0 679 680 /* Designates passed argument as undefined. */ 681 #define UNDEFINED -1 682 683 /* Dummy values for unused LFS control parameters. */ 684 #define UNUSED_INT 0 685 #define UNUSED_DBL 0.0 686 687 /*************************************************************************/ 688 /* EXTERNAL FUNCTION DEFINITIONS */ 689 /*************************************************************************/ 690 691 /* binar.c */ 692 extern int binarize_V2(unsigned char **, int *, int *, 693 unsigned char *, const int, const int, 694 int *, const int, const int, 695 const ROTGRIDS *, const LFSPARMS *); 696 extern int binarize_image_V2(unsigned char **, int *, int *, 697 unsigned char *, const int, const int, 698 const int *, const int, const int, 699 const int, const ROTGRIDS *); 700 extern int dirbinarize(const unsigned char *, const int, const ROTGRIDS *); 701 702 /* block.c */ 703 extern int block_offsets(int **, int *, int *, const int, const int, 704 const int, const int); 705 extern int low_contrast_block(const int, const int, 706 unsigned char *, const int, const int, const LFSPARMS *); 707 extern int find_valid_block(int *, int *, int *, int *, int *, 708 const int, const int, const int, const int, 709 const int, const int); 710 extern void set_margin_blocks(int *, const int, const int, const int); 711 712 /* contour.c */ 713 int allocate_contour(int **ocontour_x, int **ocontour_y, 714 int **ocontour_ex, int **ocontour_ey, const int ncontour); 715 extern void free_contour(int *, int *, int *, int *); 716 extern int get_high_curvature_contour(int **, int **, int **, int **, int *, 717 const int, const int, const int, const int, const int, 718 unsigned char *, const int, const int); 719 extern int get_centered_contour(int **, int **, int **, int **, int *, 720 const int, const int, const int, const int, const int, 721 unsigned char *, const int, const int); 722 extern int trace_contour(int **, int **, int **, int **, int *, 723 const int, const int, const int, const int, const int, 724 const int, const int, const int, 725 unsigned char *, const int, const int); 726 extern int search_contour(const int, const int, const int, 727 const int, const int, const int, const int, const int, 728 unsigned char *, const int, const int); 729 extern int min_contour_theta(int *, double *, const int, const int *, 730 const int *, const int); 731 extern void contour_limits(int *, int *, int *, int *, const int *, 732 const int *, const int); 733 extern void fix_edge_pixel_pair(int *, int *, int *, int *, 734 unsigned char *, const int, const int); 735 736 /* detect.c */ 737 extern int get_minutiae(MINUTIAE **, int **, int **, int **, 738 int **, int **, int *, int *, 739 unsigned char **, int *, int *, int *, 740 unsigned char *, const int, const int, 741 const int, const double, const LFSPARMS *); 742 743 /* dft.c */ 744 extern int dft_dir_powers(double **, unsigned char *, const int, 745 const int, const int, const DFTWAVES *, 746 const ROTGRIDS *); 747 extern int dft_power_stats(int *, double *, int *, double *, double **, 748 const int, const int, const int); 749 750 /* free.c */ 751 extern void free_dir2rad(DIR2RAD *); 752 extern void free_dftwaves(DFTWAVES *); 753 extern void free_rotgrids(ROTGRIDS *); 754 extern void free_dir_powers(double **, const int); 755 756 /* imgutil.c */ 757 extern void bits_6to8(unsigned char *, const int, const int); 758 extern void bits_8to6(unsigned char *, const int, const int); 759 extern void gray2bin(const int, const int, const int, 760 unsigned char *, const int, const int); 761 extern int pad_uchar_image(unsigned char **, int *, int *, 762 unsigned char *, const int, const int, const int, 763 const int); 764 extern void fill_holes(unsigned char *, const int, const int); 765 extern int free_path(const int, const int, const int, const int, 766 unsigned char *, const int, const int, const LFSPARMS *); 767 extern int search_in_direction(int *, int *, int *, int *, const int, 768 const int, const int, const double, const double, 769 const int, unsigned char *, const int, const int); 770 771 /* init.c */ 772 extern int init_dir2rad(DIR2RAD **, const int); 773 extern int init_dftwaves(DFTWAVES **, const double *, const int, const int); 774 extern int get_max_padding_V2(const int, const int, const int, const int); 775 extern int init_rotgrids(ROTGRIDS **, const int, const int, const int, 776 const double, const int, const int, const int, const int); 777 extern int alloc_dir_powers(double ***, const int, const int); 778 extern int alloc_power_stats(int **, double **, int **, double **, const int); 779 780 /* line.c */ 781 extern int line_points(int **, int **, int *, 782 const int, const int, const int, const int); 783 784 /* loop.c */ 785 extern int get_loop_list(int **, MINUTIAE *, const int, unsigned char *, 786 const int, const int); 787 extern int on_loop(const MINUTIA *, const int, unsigned char *, const int, 788 const int); 789 extern int on_island_lake(int **, int **, int **, int **, int *, 790 const MINUTIA *, const MINUTIA *, const int, 791 unsigned char *, const int, const int); 792 extern int on_hook(const MINUTIA *, const MINUTIA *, const int, 793 unsigned char *, const int, const int); 794 extern int is_loop_clockwise(const int *, const int *, const int, const int); 795 extern int process_loop(MINUTIAE *, const int *, const int *, 796 const int *, const int *, const int, 797 unsigned char *, const int, const int, const LFSPARMS *); 798 extern int process_loop_V2(MINUTIAE *, const int *, const int *, 799 const int *, const int *, const int, 800 unsigned char *, const int, const int, 801 int *, const LFSPARMS *); 802 extern int fill_loop(const int *, const int *, const int, 803 unsigned char *, const int, const int); 804 805 /* maps.c */ 806 extern int gen_image_maps(int **, int **, int **, int **, int *, int *, 807 unsigned char *, const int, const int, 808 const DIR2RAD *, const DFTWAVES *, 809 const ROTGRIDS *, const LFSPARMS *); 810 extern int gen_initial_maps(int **, int **, int **, 811 int *, const int, const int, 812 unsigned char *, const int, const int, 813 const DFTWAVES *, const ROTGRIDS *, const LFSPARMS *); 814 extern int interpolate_direction_map(int *, int *, const int, const int, 815 const LFSPARMS *); 816 extern int morph_TF_map(int *, const int, const int, const LFSPARMS *); 817 extern int pixelize_map(int **, const int, const int, 818 int *, const int, const int, const int); 819 extern void smooth_direction_map(int *, int *, const int, const int, 820 const DIR2RAD *, const LFSPARMS *); 821 extern int gen_high_curve_map(int **, int *, const int, const int, 822 const LFSPARMS *); 823 extern int gen_initial_imap(int **, int *, const int, const int, 824 unsigned char *, const int, const int, 825 const DFTWAVES *, const ROTGRIDS *, const LFSPARMS *); 826 extern int primary_dir_test(double **, const int *, const double *, 827 const int *, const double *, const int, 828 const LFSPARMS *); 829 extern int secondary_fork_test(double **, const int *, const double *, 830 const int *, const double *, const int, 831 const LFSPARMS *); 832 extern void remove_incon_dirs(int *, const int, const int, 833 const DIR2RAD *, const LFSPARMS *); 834 extern int test_top_edge(const int, const int, const int, const int, 835 int *, const int, const int, const DIR2RAD *, 836 const LFSPARMS *); 837 extern int test_right_edge(const int, const int, const int, const int, 838 int *, const int, const int, const DIR2RAD *, 839 const LFSPARMS *); 840 extern int test_bottom_edge(const int, const int, const int, const int, 841 int *, const int, const int, const DIR2RAD *, 842 const LFSPARMS *); 843 extern int test_left_edge(const int, const int, const int, const int, 844 int *, const int, const int, const DIR2RAD *, 845 const LFSPARMS *); 846 extern int remove_dir(int *, const int, const int, const int, const int, 847 const DIR2RAD *, const LFSPARMS *); 848 extern void average_8nbr_dir(int *, double *, int *, int *, const int, 849 const int, const int, const int, const DIR2RAD *); 850 extern int num_valid_8nbrs(int *, const int, const int, const int, const int); 851 extern void smooth_imap(int *, const int, const int, const DIR2RAD *, 852 const LFSPARMS *); 853 extern int vorticity(int *, const int, const int, const int, const int, 854 const int); 855 extern void accum_nbr_vorticity(int *, const int, const int, const int); 856 extern int curvature(int *, const int, const int, const int, const int, 857 const int); 858 859 /* matchpat.c */ 860 extern int match_1st_pair(unsigned char, unsigned char, int *, int *); 861 extern int match_2nd_pair(unsigned char, unsigned char, int *, int *); 862 extern int match_3rd_pair(unsigned char, unsigned char, int *, int *); 863 extern void skip_repeated_horizontal_pair(int *, const int, 864 unsigned char **, unsigned char **, const int, const int); 865 extern void skip_repeated_vertical_pair(int *, const int, 866 unsigned char **, unsigned char **, const int, const int); 867 868 /* minutia.c */ 869 extern int alloc_minutiae(MINUTIAE **, const int); 870 extern int realloc_minutiae(MINUTIAE *, const int); 871 extern int detect_minutiae_V2(MINUTIAE *, 872 unsigned char *, const int, const int, 873 int *, int *, int *, const int, const int, 874 const LFSPARMS *); 875 extern int update_minutiae(MINUTIAE *, MINUTIA *, unsigned char *, 876 const int, const int, const LFSPARMS *); 877 extern int update_minutiae_V2(MINUTIAE *, MINUTIA *, const int, const int, 878 unsigned char *, const int, const int, 879 const LFSPARMS *); 880 extern int sort_minutiae(MINUTIAE *, const int, const int); 881 extern int sort_minutiae_y_x(MINUTIAE *, const int, const int); 882 extern int sort_minutiae_x_y(MINUTIAE *, const int, const int); 883 extern int rm_dup_minutiae(MINUTIAE *); 884 extern void dump_minutiae(FILE *, const MINUTIAE *); 885 extern void dump_minutiae_pts(FILE *, const MINUTIAE *); 886 extern void dump_reliable_minutiae_pts(FILE *, const MINUTIAE *, const double); 887 extern int create_minutia(MINUTIA **, const int, const int, 888 const int, const int, const int, const double, 889 const int, const int, const int); 890 extern void free_minutiae(MINUTIAE *); 891 extern void free_minutia(MINUTIA *); 892 extern int remove_minutia(const int, MINUTIAE *); 893 extern int join_minutia(const MINUTIA *, const MINUTIA *, unsigned char *, 894 const int, const int, const int, const int); 895 extern int minutia_type(const int); 896 extern int is_minutia_appearing(const int, const int, const int, const int); 897 extern int choose_scan_direction(const int, const int); 898 int scan4minutiae(MINUTIAE *, unsigned char *, const int, const int, 899 const int *, const int *, const int, const int, 900 const int, const int, const int, const int, 901 const int, const int, const int, const LFSPARMS *); 902 extern int scan4minutiae_horizontally(MINUTIAE *, unsigned char *, 903 const int, const int, const int, const int, 904 const int, const int, const int, const int, 905 const LFSPARMS *); 906 extern int scan4minutiae_horizontally_V2(MINUTIAE *, 907 unsigned char *, const int, const int, 908 int *, int *, int *, 909 const LFSPARMS *); 910 extern int scan4minutiae_vertically(MINUTIAE *, unsigned char *, 911 const int, const int, const int, const int, 912 const int, const int, const int, const int, 913 const LFSPARMS *); 914 extern int rescan4minutiae_horizontally(MINUTIAE *, unsigned char *bdata, 915 const int, const int, const int *, const int *, 916 const int, const int, const int, const int, 917 const int, const int, const int, const int, 918 const LFSPARMS *); 919 extern int scan4minutiae_vertically_V2(MINUTIAE *, 920 unsigned char *, const int, const int, 921 int *, int *, int *, const LFSPARMS *); 922 extern int rescan4minutiae_vertically(MINUTIAE *, unsigned char *, 923 const int, const int, const int *, const int *, 924 const int, const int, const int, const int, 925 const int, const int, const int, const int, 926 const LFSPARMS *); 927 extern int rescan_partial_horizontally(const int, MINUTIAE *, 928 unsigned char *, const int, const int, 929 const int *, const int *, 930 const int, const int, const int, const int, 931 const int, const int, const int, const int, 932 const LFSPARMS *); 933 extern int rescan_partial_vertically(const int, MINUTIAE *, 934 unsigned char *, const int, const int, 935 const int *, const int *, 936 const int, const int, const int, const int, 937 const int, const int, const int, const int, 938 const LFSPARMS *); 939 extern int get_nbr_block_index(int *, const int, const int, const int, 940 const int, const int); 941 extern int adjust_horizontal_rescan(const int, int *, int *, int *, int *, 942 const int, const int, const int, const int, const int); 943 extern int adjust_vertical_rescan(const int, int *, int *, int *, int *, 944 const int, const int, const int, const int, const int); 945 extern int process_horizontal_scan_minutia(MINUTIAE *, const int, const int, 946 const int, const int, 947 unsigned char *, const int, const int, 948 const int, const int, const LFSPARMS *); 949 extern int process_horizontal_scan_minutia_V2(MINUTIAE *, 950 const int, const int, const int, const int, 951 unsigned char *, const int, const int, 952 int *, int *, int *, const LFSPARMS *); 953 extern int process_vertical_scan_minutia(MINUTIAE *, const int, const int, 954 const int, const int, 955 unsigned char *, const int, const int, 956 const int, const int, const LFSPARMS *); 957 extern int process_vertical_scan_minutia_V2(MINUTIAE *, const int, const int, 958 const int, const int, 959 unsigned char *, const int, const int, 960 int *, int *, int *, const LFSPARMS *); 961 extern int update_minutiae_V2(MINUTIAE *, MINUTIA *, const int, const int, 962 unsigned char *, const int, const int, 963 const LFSPARMS *); 964 extern int adjust_high_curvature_minutia(int *, int *, int *, int *, int *, 965 const int, const int, const int, const int, 966 unsigned char *, const int, const int, 967 MINUTIAE *, const LFSPARMS *); 968 extern int adjust_high_curvature_minutia_V2(int *, int *, int *, 969 int *, int *, const int, const int, 970 const int, const int, 971 unsigned char *, const int, const int, 972 int *, MINUTIAE *, const LFSPARMS *); 973 extern int get_low_curvature_direction(const int, const int, const int, 974 const int); 975 void lfs2nist_minutia_XYT(int *ox, int *oy, int *ot, 976 const MINUTIA *minutia, const int iw, const int ih); 977 978 /* quality.c */ 979 extern int gen_quality_map(int **, int *, int *, int *, int *, 980 const int, const int); 981 extern int combined_minutia_quality(MINUTIAE *, int *, const int, const int, 982 const int, unsigned char *, const int, const int, 983 const int, const double); 984 985 /* remove.c */ 986 extern int remove_false_minutia(MINUTIAE *, 987 unsigned char *, const int, const int, 988 int *, const int, const int, const LFSPARMS *); 989 extern int remove_false_minutia_V2(MINUTIAE *, 990 unsigned char *, const int, const int, 991 int *, int *, int *, const int, const int, 992 const LFSPARMS *); 993 994 /* ridges.c */ 995 extern int count_minutiae_ridges(MINUTIAE *, 996 unsigned char *, const int, const int, 997 const LFSPARMS *); 998 999 /* shape.c */ 1000 extern void free_shape(SHAPE *); 1001 extern int shape_from_contour(SHAPE **, const int *, const int *, const int); 1002 1003 /* sort.c */ 1004 extern int sort_indices_int_inc(int **, int *, const int); 1005 extern int sort_indices_double_inc(int **, double *, const int); 1006 extern void bubble_sort_int_inc_2(int *, int *, const int); 1007 extern void bubble_sort_double_inc_2(double *, int *, const int); 1008 extern void bubble_sort_double_dec_2(double *, int *, const int); 1009 extern void bubble_sort_int_inc(int *, const int); 1010 1011 /* util.c */ 1012 extern int maxv(const int *, const int); 1013 extern int minv(const int *, const int); 1014 extern int minmaxs(int **, int **, int **, int *, int *, 1015 const int *, const int); 1016 extern double distance(const int, const int, const int, const int); 1017 extern double squared_distance(const int, const int, const int, const int); 1018 extern int in_int_list(const int, const int *, const int); 1019 extern int remove_from_int_list(const int, int *, const int); 1020 extern int find_incr_position_dbl(const double, double *, const int); 1021 extern double angle2line(const int, const int, const int, const int); 1022 extern int line2direction(const int, const int, const int, const int, 1023 const int); 1024 extern int closest_dir_dist(const int, const int, const int); 1025 1026 /*************************************************************************/ 1027 /* EXTERNAL GLOBAL VARIABLE DEFINITIONS */ 1028 /*************************************************************************/ 1029 extern double g_dft_coefs[]; 1030 extern LFSPARMS g_lfsparms; 1031 extern LFSPARMS g_lfsparms_V2; 1032 extern int g_nbr8_dx[]; 1033 extern int g_nbr8_dy[]; 1034 extern int g_chaincodes_nbr8[]; 1035 extern FEATURE_PATTERN g_feature_patterns[]; 1036 1037 #endif 1038