GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 56 / 0 / 56
Functions: 100.0% 5 / 0 / 5
Branches: 90.6% 29 / 0 / 32

libfprint/nbis/mindtct/matchpat.c
Line Branch Exec Source
1 /*******************************************************************************
2
3 License:
4 This software and/or related materials was developed at the National Institute
5 of Standards and Technology (NIST) by employees of the Federal Government
6 in the course of their official duties. Pursuant to title 17 Section 105
7 of the United States Code, this software is not subject to copyright
8 protection and is in the public domain.
9
10 This software and/or related materials have been determined to be not subject
11 to the EAR (see Part 734.3 of the EAR for exact details) because it is
12 a publicly available technology and software, and is freely distributed
13 to any interested party with no licensing requirements. Therefore, it is
14 permissible to distribute this software as a free download from the internet.
15
16 Disclaimer:
17 This software and/or related materials was developed to promote biometric
18 standards and biometric technology testing for the Federal Government
19 in accordance with the USA PATRIOT Act and the Enhanced Border Security
20 and Visa Entry Reform Act. Specific hardware and software products identified
21 in this software were used in order to perform the software development.
22 In no case does such identification imply recommendation or endorsement
23 by the National Institute of Standards and Technology, nor does it imply that
24 the products and equipment identified are necessarily the best available
25 for the purpose.
26
27 This software and/or related materials are provided "AS-IS" without warranty
28 of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY,
29 NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY
30 or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the
31 licensed product, however used. In no event shall NIST be liable for any
32 damages and/or costs, including but not limited to incidental or consequential
33 damages of any kind, including economic damage or injury to property and lost
34 profits, regardless of whether NIST shall be advised, have reason to know,
35 or in fact shall know of the possibility.
36
37 By using this software, you agree to bear all risk relating to quality,
38 use and performance of the software and/or related materials. You agree
39 to hold the Government harmless from any claim arising from your use
40 of the software.
41
42 *******************************************************************************/
43
44
45 /***********************************************************************
46 LIBRARY: LFS - NIST Latent Fingerprint System
47
48 FILE: MATCHPAT.C
49 AUTHOR: Michael D. Garris
50 DATE: 05/11/1999
51 UPDATED: 03/16/2005 by MDG
52
53 Contains routines responsible for matching minutia feature
54 patterns as part of the NIST Latent Fingerprint System (LFS).
55
56 ***********************************************************************
57 ROUTINES:
58 match_1st_pair()
59 match_2nd_pair()
60 match_3rd_pair()
61 skip_repeated_horizontal_pair()
62 skip_repeated_vertical_pair()
63 ***********************************************************************/
64
65 #include <stdio.h>
66 #include <lfs.h>
67
68 /*************************************************************************
69 **************************************************************************
70 #cat: match_1st_pair - Determines which of the g_feature_patterns[] have their
71 #cat: first pixel pair match the specified pixel pair.
72
73 Input:
74 p1 - first pixel value of pair
75 p2 - second pixel value of pair
76 Output:
77 possible - list of matching g_feature_patterns[] indices
78 nposs - number of matches
79 Return Code:
80 nposs - number of matches
81 *************************************************************************/
82 5984499 int match_1st_pair(unsigned char p1, unsigned char p2,
83 int *possible, int *nposs)
84 {
85 5984499 int i;
86
87 /* Set possibilities to 0 */
88 5984499 *nposs = 0;
89
90 /* Foreach set of feature pairs ... */
91
2/2
✓ Branch 7 → 3 taken 59844990 times.
✓ Branch 7 → 8 taken 5984499 times.
65829489 for(i = 0; i < NFEATURES; i++){
92 /* If current scan pair matches first pair for feature ... */
93
2/2
✓ Branch 3 → 4 taken 28357846 times.
✓ Branch 3 → 6 taken 31487144 times.
59844990 if((p1==g_feature_patterns[i].first[0]) &&
94
2/2
✓ Branch 4 → 5 taken 16388430 times.
✓ Branch 4 → 6 taken 11969416 times.
28357846 (p2==g_feature_patterns[i].first[1])){
95 /* Store feature as a possible match. */
96 16388430 possible[*nposs] = i;
97 /* Bump number of stored possibilities. */
98 16388430 (*nposs)++;
99 }
100 }
101
102 /* Return number of stored possibilities. */
103 5984499 return(*nposs);
104 }
105
106 /*************************************************************************
107 **************************************************************************
108 #cat: match_2nd_pair - Determines which of the passed g_feature_patterns[] have
109 #cat: their second pixel pair match the specified pixel pair.
110
111 Input:
112 p1 - first pixel value of pair
113 p2 - second pixel value of pair
114 possible - list of potentially-matching g_feature_patterns[] indices
115 nposs - number of potential matches
116 Output:
117 possible - list of matching g_feature_patterns[] indices
118 nposs - number of matches
119 Return Code:
120 nposs - number of matches
121 *************************************************************************/
122 5957656 int match_2nd_pair(unsigned char p1, unsigned char p2,
123 int *possible, int *nposs)
124 {
125 5957656 int i;
126 5957656 int tnposs;
127
128 /* Store input possibilities. */
129 5957656 tnposs = *nposs;
130 /* Reset output possibilities to 0. */
131 5957656 *nposs = 0;
132
133 /* If current scan pair values are the same ... */
134
2/2
✓ Branch 2 → 7 taken 554390 times.
✓ Branch 2 → 9 taken 5403266 times.
5957656 if(p1 == p2)
135 /* Simply return because pair can't be a second feature pair. */
136 return(*nposs);
137
138 /* Foreach possible match based on first pair ... */
139
2/2
✓ Branch 7 → 3 taken 1658564 times.
✓ Branch 7 → 8 taken 554390 times.
2212954 for(i = 0; i < tnposs; i++){
140 /* If current scan pair matches second pair for feature ... */
141
2/2
✓ Branch 3 → 4 taken 829655 times.
✓ Branch 3 → 6 taken 828909 times.
1658564 if((p1==g_feature_patterns[possible[i]].second[0]) &&
142
1/2
✓ Branch 4 → 5 taken 829655 times.
✗ Branch 4 → 6 not taken.
829655 (p2==g_feature_patterns[possible[i]].second[1])){
143 /* Store feature as a possible match. */
144 829655 possible[*nposs] = possible[i];
145 /* Bump number of stored possibilities. */
146 829655 (*nposs)++;
147 }
148 }
149
150 /* Return number of stored possibilities. */
151 554390 return(*nposs);
152 }
153
154 /*************************************************************************
155 **************************************************************************
156 #cat: match_3rd_pair - Determines which of the passed g_feature_patterns[] have
157 #cat: their third pixel pair match the specified pixel pair.
158
159 Input:
160 p1 - first pixel value of pair
161 p2 - second pixel value of pair
162 possible - list of potentially-matching g_feature_patterns[] indices
163 nposs - number of potential matches
164 Output:
165 possible - list of matching g_feature_patterns[] indices
166 nposs - number of matches
167 Return Code:
168 nposs - number of matches
169 *************************************************************************/
170 554390 int match_3rd_pair(unsigned char p1, unsigned char p2,
171 int *possible, int *nposs)
172 {
173 554390 int i;
174 554390 int tnposs;
175
176 /* Store input possibilities. */
177 554390 tnposs = *nposs;
178 /* Reset output possibilities to 0. */
179 554390 *nposs = 0;
180
181 /* Foreach possible match based on first and second pairs ... */
182
2/2
✓ Branch 7 → 3 taken 829655 times.
✓ Branch 7 → 8 taken 554390 times.
1384045 for(i = 0; i < tnposs; i++){
183 /* If current scan pair matches third pair for feature ... */
184
2/2
✓ Branch 3 → 4 taken 186471 times.
✓ Branch 3 → 6 taken 643184 times.
829655 if((p1==g_feature_patterns[possible[i]].third[0]) &&
185
2/2
✓ Branch 4 → 5 taken 58861 times.
✓ Branch 4 → 6 taken 127610 times.
186471 (p2==g_feature_patterns[possible[i]].third[1])){
186 /* Store feature as a possible match. */
187 58861 possible[*nposs] = possible[i];
188 /* Bump number of stored possibilities. */
189 58861 (*nposs)++;
190 }
191 }
192
193 /* Return number of stored possibilities. */
194 554390 return(*nposs);
195 }
196
197 /*************************************************************************
198 **************************************************************************
199 #cat: skip_repeated_horizontal_pair - Takes the location of two pixel in
200 #cat: adjacent pixel rows within an image region and skips
201 #cat: rightward until the either the pixel pair no longer repeats
202 #cat: itself or the image region is exhausted.
203
204 Input:
205 cx - current x-coord of starting pixel pair
206 ex - right edge of the image region
207 p1ptr - pointer to current top pixel in pair
208 p2ptr - pointer to current bottom pixel in pair
209 iw - width (in pixels) of image
210 ih - height (in pixels) of image
211 Output:
212 cx - x-coord of where rightward skip terminated
213 p1ptr - points to top pixel where rightward skip terminated
214 p2ptr - points to bottom pixel where rightward skip terminated
215 *************************************************************************/
216 277303 void skip_repeated_horizontal_pair(int *cx, const int ex,
217 unsigned char **p1ptr, unsigned char **p2ptr,
218 const int iw, const int ih)
219 {
220 277303 int old1, old2;
221
222 /* Store starting pixel pair. */
223 277303 old1 = **p1ptr;
224 277303 old2 = **p2ptr;
225
226 /* Bump horizontally to next pixel pair. */
227 277303 (*cx)++;
228 277303 (*p1ptr)++;
229 277303 (*p2ptr)++;
230
231 /* While not at right of scan region... */
232
1/2
✓ Branch 6 → 3 taken 569374 times.
✗ Branch 6 → 7 not taken.
569374 while(*cx < ex){
233 /* If one or the other pixels in the new pair are different */
234 /* from the starting pixel pair... */
235
4/4
✓ Branch 3 → 4 taken 440370 times.
✓ Branch 3 → 7 taken 129004 times.
✓ Branch 4 → 5 taken 292071 times.
✓ Branch 4 → 7 taken 148299 times.
569374 if((**p1ptr != old1) || (**p2ptr != old2))
236 /* Done skipping repreated pixel pairs. */
237 return;
238 /* Otherwise, bump horizontally to next pixel pair. */
239 292071 (*cx)++;
240 292071 (*p1ptr)++;
241 292071 (*p2ptr)++;
242 }
243 }
244
245 /*************************************************************************
246 **************************************************************************
247 #cat: skip_repeated_vertical_pair - Takes the location of two pixel in
248 #cat: adjacent pixel columns within an image region and skips
249 #cat: downward until the either the pixel pair no longer repeats
250 #cat: itself or the image region is exhausted.
251
252 Input:
253 cy - current y-coord of starting pixel pair
254 ey - bottom of the image region
255 p1ptr - pointer to current left pixel in pair
256 p2ptr - pointer to current right pixel in pair
257 iw - width (in pixels) of image
258 ih - height (in pixels) of image
259 Output:
260 cy - y-coord of where downward skip terminated
261 p1ptr - points to left pixel where downward skip terminated
262 p2ptr - points to right pixel where donward skip terminated
263 *************************************************************************/
264 277087 void skip_repeated_vertical_pair(int *cy, const int ey,
265 unsigned char **p1ptr, unsigned char **p2ptr,
266 const int iw, const int ih)
267 {
268 277087 int old1, old2;
269
270 /* Store starting pixel pair. */
271 277087 old1 = **p1ptr;
272 277087 old2 = **p2ptr;
273
274 /* Bump vertically to next pixel pair. */
275 277087 (*cy)++;
276 277087 (*p1ptr)+=iw;
277 277087 (*p2ptr)+=iw;
278
279 /* While not at bottom of scan region... */
280
1/2
✓ Branch 6 → 3 taken 451709 times.
✗ Branch 6 → 7 not taken.
451709 while(*cy < ey){
281 /* If one or the other pixels in the new pair are different */
282 /* from the starting pixel pair... */
283
4/4
✓ Branch 3 → 4 taken 322731 times.
✓ Branch 3 → 7 taken 128978 times.
✓ Branch 4 → 5 taken 174622 times.
✓ Branch 4 → 7 taken 148109 times.
451709 if((**p1ptr != old1) || (**p2ptr != old2))
284 /* Done skipping repreated pixel pairs. */
285 return;
286 /* Otherwise, bump vertically to next pixel pair. */
287 174622 (*cy)++;
288 174622 (*p1ptr)+=iw;
289 174622 (*p2ptr)+=iw;
290 }
291 }
292
293