/* Convert numeric curvature invariants to byte encoding */ /* Last edited on 2015-01-20 16:45:49 by stolfilocal */ #include #include #include #include #include #include TYPE Options = struct ??? { char *input; /* Input float chain file (without ".flv") */ char *output; /* Output float/curv chain file name (without ".flc") */ double sigma; /* Filtering scale */ } ???; int main(int argc, char **argv ) { { /* with */ ??? o = pz_get_options(int argc, char **argv); ??? rcv = pz_double_chain_read(open_read(o.input & ".fcv", TRUE), header_only := FALSE); ??? cv = rcv.c^; ??? cmt = rcv.cmt & "\n" & PZEncodeCurvatureComments(o, (cv.ne)); ??? cc = QuantizeInvariantChain(cv, o.sigma)^; ??? ccCmt = txtcat(cmt & "\n" , "Encoded Curvature - computed at sample points"); /* do */ pz_symbol_chain_write(open_write(o.output & ".cvc", TRUE), ccCmt, cc, o.sigma);; } } /* Main */ pz_symbol_chain_t *QuantizeInvariantChain( pz_double_chain_t *c, double sigma ) /* Given the numerical curvature chain, converts it to a coded curvature chain. */ { { /* with */ ??? NP = (c.ne); ??? rcvc = pz_symbol_chain_new(NP); ??? cvc = rcvc^; /* do */ for (i = 0; i <= NP-1 ; i++){ cvc[i] = pz_symbol_encode(c[i], sigma); }; return rcvc; } } /* QuantizeInvariantChain */ 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, "-input"); o.input = argparser_get_next(pp); argparser_get_keyword(pp, "-output"); o.output = argparser_get_next(pp); argparser_get_keyword(pp, "-sigma"); o.sigma = argparser_get_next_double(pp); argparser_finish(pp); EXCEPT | ParseParams.Error ==> fprintf(stderr, "Usage: pz_encode_curvature \\\n"); fprintf(stderr, " -input FILE \\\n"); fprintf(stderr, " -output FILE \\\n"); fprintf(stderr, " -sigma NUMBER \n"); Process.Exit(1);; };; }; return o } /* GetOptions */ char *PZEncodeCurvatureComments( Options *o, unsigned nSamples ) { { /* with */ ??? wr = NEW(TextFILE *).init(); /* do */ fprintf( wr, "pz_encode_curvature:\n"); fprintf(wr, " input: %s\n", o.input ); fprintf(wr, " output: %s\n", o.output ); fprintf(wr, " sigma: %s\n", Fmt.LongReal(o.sigma) ); fprintf( wr, " nSamples: " & Fmt.Int(nSamples)); return(TextFILE *oText(wr)); } /* ){ */; } /* PZEncodeCurvatureComments */ { /* 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. */