xytreps.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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: XYTREPS.C
  40. AUTHOR: Michael D. Garris
  41. DATE: 09/16/2004
  42. UPDATED: 01/11/2012
  43. Contains routines useful in converting minutiae in LFS "native"
  44. representation into other representations, such as
  45. M1 (ANSI INCITS 378-2004) & NIST internal representations.
  46. ***********************************************************************
  47. ROUTINES:
  48. lfs2nist_minutia_XTY()
  49. lfs2m1_minutia_XTY()
  50. lfs2nist_format()
  51. ***********************************************************************/
  52. #include "lfs.h"
  53. //#include <defs.h>
  54. /*************************************************************************
  55. **************************************************************************
  56. #cat: lfs2nist_minutia_XYT - Converts XYT minutiae attributes in LFS native
  57. #cat: representation to NIST internal representation
  58. Input:
  59. minutia - LFS minutia structure containing attributes to be converted
  60. Output:
  61. ox - NIST internal based x-pixel coordinate
  62. oy - NIST internal based y-pixel coordinate
  63. ot - NIST internal based minutia direction/orientation
  64. **************************************************************************/
  65. void lfs2nist_minutia_XYT(int *ox, int *oy, int *ot, const MINUTIA *minutia, const int iw, const int ih){
  66. int x, y, t;
  67. float degrees_per_unit;
  68. /* XYT's according to NIST internal rep: */
  69. /* 1. pixel coordinates with origin bottom-left */
  70. /* 2. orientation in degrees on range [0..360] */
  71. /* with 0 pointing east and increasing counter */
  72. /* clockwise (same as M1) */
  73. /* 3. direction pointing out and away from the */
  74. /* ridge ending or bifurcation valley */
  75. /* (opposite direction from M1) */
  76. x = minutia->x;
  77. y = ih - minutia->y;
  78. degrees_per_unit = 180 / (float)NUM_DIRECTIONS;
  79. t = (270 - sround(minutia->direction * degrees_per_unit)) % 360;
  80. if(t < 0){
  81. t += 360;
  82. }
  83. *ox = x;
  84. *oy = y;
  85. *ot = t;
  86. }
  87. /*************************************************************************
  88. **************************************************************************
  89. #cat: lfs2m1_minutia_XYT - Converts XYT minutiae attributes in LFS native
  90. #cat: representation to M1 (ANSI INCITS 378-2004) representation
  91. Input:
  92. minutia - LFS minutia structure containing attributes to be converted
  93. Output:
  94. ox - M1 based x-pixel coordinate
  95. oy - M1 based y-pixel coordinate
  96. ot - M1 based minutia direction/orientation
  97. **************************************************************************/
  98. void lfs2m1_minutia_XYT(int *ox, int *oy, int *ot, const MINUTIA *minutia){
  99. int x, y, t;
  100. float degrees_per_unit;
  101. /* XYT's according to M1 (ANSI INCITS 378-2004): */
  102. /* 1. pixel coordinates with origin top-left */
  103. /* 2. orientation in degrees on range [0..179] */
  104. /* with 0 pointing east and increasing counter */
  105. /* clockwise */
  106. /* 3. direction pointing up the ridge ending or */
  107. /* bifurcaiton valley */
  108. x = minutia->x;
  109. y = minutia->y;
  110. degrees_per_unit = 180 / (float)NUM_DIRECTIONS;
  111. t = (90 - sround(minutia->direction * degrees_per_unit)) % 360;
  112. if(t < 0){
  113. t += 360;
  114. }
  115. /* range of theta is 0..179 because angles are in units of 2 degress */
  116. t = t / 2;
  117. *ox = x;
  118. *oy = y;
  119. *ot = t;
  120. }
  121. /*************************************************************************
  122. **************************************************************************
  123. #cat: lfs2nist_format - Takes a minutiae data structure and converts
  124. #cat: the XYT minutiae attributes in LFS native
  125. #cat: representation to NIST internal representation
  126. Input:
  127. iminutiae - minutiae data structure
  128. iw - width (in pixels) of the grayscale image
  129. ih - height (in pixels) of the grayscale image
  130. Output:
  131. iminutiae - overwrite each minutia element in the minutiae data
  132. sturcture convernt to nist internal minutiae format
  133. **************************************************************************/
  134. void lfs2nist_format(MINUTIAE *iminutiae, int iw, int ih)
  135. {
  136. int i, ox, oy, ot, oq;
  137. MINUTIA *minutia;
  138. for (i = 0; i < iminutiae->num; i++)
  139. {
  140. minutia = iminutiae->list[i];
  141. lfs2nist_minutia_XYT(&ox, &oy, &ot, minutia, iw, ih);
  142. oq = sround(minutia->reliability * 100.0);
  143. minutia->x = ox;
  144. minutia->y = oy;
  145. minutia->direction = ot;
  146. minutia->reliability = (double)oq;
  147. }
  148. }