getmin.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*******************************************************************************
  2. License:
  3. This software and/or related materials was developed at the National Institute
  4. of Standards and Technology (NIST) by employees of the Federal Government
  5. in the course of their official duties. Pursuant to title 17 Section 105
  6. of the United States Code, this software is not subject to copyright
  7. protection and is in the public domain.
  8. This software and/or related materials have been determined to be not subject
  9. to the EAR (see Part 734.3 of the EAR for exact details) because it is
  10. a publicly available technology and software, and is freely distributed
  11. to any interested party with no licensing requirements. Therefore, it is
  12. permissible to distribute this software as a free download from the internet.
  13. Disclaimer:
  14. This software and/or related materials was developed to promote biometric
  15. standards and biometric technology testing for the Federal Government
  16. in accordance with the USA PATRIOT Act and the Enhanced Border Security
  17. and Visa Entry Reform Act. Specific hardware and software products identified
  18. in this software were used in order to perform the software development.
  19. In no case does such identification imply recommendation or endorsement
  20. by the National Institute of Standards and Technology, nor does it imply that
  21. the products and equipment identified are necessarily the best available
  22. for the purpose.
  23. This software and/or related materials are provided "AS-IS" without warranty
  24. of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY,
  25. NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY
  26. or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the
  27. licensed product, however used. In no event shall NIST be liable for any
  28. damages and/or costs, including but not limited to incidental or consequential
  29. damages of any kind, including economic damage or injury to property and lost
  30. profits, regardless of whether NIST shall be advised, have reason to know,
  31. or in fact shall know of the possibility.
  32. By using this software, you agree to bear all risk relating to quality,
  33. use and performance of the software and/or related materials. You agree
  34. to hold the Government harmless from any claim arising from your use
  35. of the software.
  36. *******************************************************************************/
  37. /***********************************************************************
  38. LIBRARY: LFS - NIST Latent Fingerprint System
  39. FILE: GETMIN.C
  40. AUTHOR: Michael D. Garris
  41. DATE: 09/10/2004
  42. UPDATED: 03/16/2005 by MDG
  43. Takes an 8-bit grayscale fingerpinrt image and detects minutiae
  44. as part of the NIST Latent Fingerprint System (LFS), returning
  45. minutiae with final reliabilities and maps including a merged
  46. quality map.
  47. ***********************************************************************
  48. ROUTINES:
  49. get_minutiae()
  50. ***********************************************************************/
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include "lfs.h"
  54. /*************************************************************************
  55. **************************************************************************
  56. #cat: get_minutiae - Takes a grayscale fingerprint image, binarizes the input
  57. #cat: image, and detects minutiae points using LFS Version 2.
  58. #cat: The routine passes back the detected minutiae, the
  59. #cat: binarized image, and a set of image quality maps.
  60. Input:
  61. idata - grayscale fingerprint image data
  62. iw - width (in pixels) of the grayscale image
  63. ih - height (in pixels) of the grayscale image
  64. id - pixel depth (in bits) of the grayscale image
  65. ppmm - the scan resolution (in pixels/mm) of the grayscale image
  66. lfsparms - parameters and thresholds for controlling LFS
  67. Output:
  68. ominutiae - points to a structure containing the
  69. detected minutiae
  70. oquality_map - resulting integrated image quality map
  71. odirection_map - resulting direction map
  72. olow_contrast_map - resulting low contrast map
  73. olow_flow_map - resulting low ridge flow map
  74. ohigh_curve_map - resulting high curvature map
  75. omap_w - width (in blocks) of image maps
  76. omap_h - height (in blocks) of image maps
  77. obdata - points to binarized image data
  78. obw - width (in pixels) of binarized image
  79. obh - height (in pixels) of binarized image
  80. obd - pixel depth (in bits) of binarized image
  81. Return Code:
  82. Zero - successful completion
  83. Negative - system error
  84. **************************************************************************/
  85. int get_minutiae(MINUTIAE **ominutiae, int **oquality_map,
  86. int **odirection_map, int **olow_contrast_map,
  87. int **olow_flow_map, int **ohigh_curve_map,
  88. int *omap_w, int *omap_h,
  89. unsigned char **obdata, int *obw, int *obh, int *obd,
  90. unsigned char *idata, const int iw, const int ih,
  91. const int id, const double ppmm, const LFSPARMS *lfsparms)
  92. {
  93. int ret;
  94. MINUTIAE *minutiae;
  95. int *direction_map, *low_contrast_map, *low_flow_map;
  96. int *high_curve_map, *quality_map;
  97. int map_w, map_h;
  98. unsigned char *bdata;
  99. int bw, bh;
  100. /* If input image is not 8-bit grayscale ... */
  101. if(id != 8){
  102. fprintf(stderr, "ERROR : get_minutiae : input image pixel ");
  103. fprintf(stderr, "depth = %d != 8.\n", id);
  104. return(-2);
  105. }
  106. /* Detect minutiae in grayscale fingerpeint image. */
  107. if((ret = lfs_detect_minutiae_V2(&minutiae,
  108. &direction_map, &low_contrast_map,
  109. &low_flow_map, &high_curve_map,
  110. &map_w, &map_h,
  111. &bdata, &bw, &bh,
  112. idata, iw, ih, lfsparms))){
  113. return(ret);
  114. }
  115. /* Build integrated quality map. */
  116. if((ret = gen_quality_map(&quality_map,
  117. direction_map, low_contrast_map,
  118. low_flow_map, high_curve_map, map_w, map_h))){
  119. free_minutiae(minutiae);
  120. free(direction_map);
  121. free(low_contrast_map);
  122. free(low_flow_map);
  123. free(high_curve_map);
  124. free(bdata);
  125. return(ret);
  126. }
  127. /* Assign reliability from quality map. */
  128. if((ret = combined_minutia_quality(minutiae, quality_map, map_w, map_h,
  129. lfsparms->blocksize,
  130. idata, iw, ih, id, ppmm))){
  131. free_minutiae(minutiae);
  132. free(direction_map);
  133. free(low_contrast_map);
  134. free(low_flow_map);
  135. free(high_curve_map);
  136. free(quality_map);
  137. free(bdata);
  138. return(ret);
  139. }
  140. /* Set output pointers. */
  141. *ominutiae = minutiae;
  142. *oquality_map = quality_map;
  143. *odirection_map = direction_map;
  144. *olow_contrast_map = low_contrast_map;
  145. *olow_flow_map = low_flow_map;
  146. *ohigh_curve_map = high_curve_map;
  147. *omap_w = map_w;
  148. *omap_h = map_h;
  149. *obdata = bdata;
  150. *obw = bw;
  151. *obh = bh;
  152. *obd = id;
  153. /* Return normally. */
  154. return(0);
  155. }