/* Computes a grey scale image showing matches between two numeric chains */ /* Last edited on 2015-01-20 16:46:51 by stolfilocal */ #include #include #include #include #include #include TYPE Options = struct ??? { char *xChain; /* Input invariant chain file (without ".fcv") */ char *yChain; /* Input invariant chain file (without ".fcv") */ char *outFile; /* Output ".pgm" file */ } ???; int main(int argc, char **argv ) VAR d: double; { { /* with */ ??? o = pz_get_options(int argc, char **argv); ??? exr = ReadCurvatureChain(o.xChain); ??? ex = exr.c^; ??? eyr = ReadCurvatureChain(o.yChain); ??? ey = eyr.c^; ??? NEX = (ex.ne); ??? NEY = (ey.ne); ??? mImage = pz_image_new(NEY, NEX)^; /* do */ for (j = 0; j <= NEX-1 ; j++){ for (i = 0; i <= NEY-1 ; i++){ /* d = ComputeSqueezeDistance(-ey[NEY-1-i], ex[j]); */ d = ComputeAlphaDistance(-ey[NEY-1-i], ex[j]); mImage[i,j] = 255 - ROUND(255.0e0 * (1.0e0 - d)); ; };; }; pz_image_write_pgm(o.outFile, mImage);; } /* with */ } /* Main */ pz_double_chain_read_data ReadCurvatureChain( char *name ) { { /* with */ ??? fName = txtcat(name , ".fcv"); /* do */ fprintf(stderr, fName & "\n"); return pz_double_chain_read(open_read(fName, TRUE), header_only = FALSE); } } /* ReadCurvatureChain */ <* UNUSED ); void NormalizedDistance( double_vec_t *d, double dMax ) { if (( dMax < 1.0e0 )){ dMax = 1.0e0 ;}; { /* with */ ??? N = (d.ne); /* do */ for (i = 0; i <= N-1 ; i++){ d[i] = d[i] / dMax;; }; ; } } /* NormalizedDistance */ <*UNUSED); double ComputeSqueezeDistance( double a, double b ) CONST Sigma == 2.0e0; { { /* with */ ??? d = (a - b)/Sigma; /* do */ return Math.exp(-d*d); }; } /* ComputeSqueezeDistance */ double ComputeAlphaDistance( double a, double b ) CONST Delta == 0.01e0; Epsilon == 0.01e0; { { /* with */ ??? delta2 = Delta * Delta; ??? epsilon2 = Epsilon * Epsilon; ??? s = a + b, s2 = s*s; ??? d = a - b, d2 = d*d; /* do */ return (delta2 * s2 + epsilon2) / (d2 + delta2 * s2 + epsilon2) ;; }; } /* ComputeAlphaDistance */ Options pz_get_options(int argc, char **argv ) VAR o: Options; { argparser_t *pp = argparser_new(stderr, argc, argv); argparser_set_help(pp, PROG_NAME " version " PROG_VERS ", usage:\n" PROG_HELP); argparser_set_info(pp, PROG_INFO); argparser_process_help_info_options(pp); { /* with */ /* do */ TRY argparser_get_keyword(pp, "-xChain"); o.xChain = argparser_get_next(pp); argparser_get_keyword(pp, "-yChain"); o.yChain = argparser_get_next(pp); argparser_get_keyword(pp, "-outFile"); o.outFile = argparser_get_next(pp); argparser_finish(pp); EXCEPT | ParseParams.Error ==> fprintf(stderr, "Usage: pz_match_image \\\n"); fprintf(stderr, " -xChain NAME \\\n"); fprintf(stderr, " -yChain NAME \\\n"); fprintf(stderr, " -outFile NAME \n"); Process.Exit(1);; };; }; return o } /* GetOptions */ { /* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP). Authors: Helena C. G. Leitão and Jorge Stolfi. This file can be freely distributed, used, and modified, provided that this copyright and authorship notice is preserved, and that any modified versions are clearly marked as such. This software has NO WARRANTY of correctness or applicability for any purpose. Neither the authors nor their employers chall be held responsible for any losses or damages that may result from its use. */