#ifndef pz_symbol_chain_H #define pz_symbol_chain_H /* Compressed sequences of real samples. */ /* Last edited on 2015-01-20 16:50:09 by stolfilocal */ #include #include #include typedef sbyte_vec_t pz_symbol_chain_t; /* A "pz_symbol_chain_t" is a sequence,open or closed, of curvature samples that have been quantized and represented as "pz_symbol_t" values. */ /* BASIC MANIPULATION */ /* The "DoXXX" procedures below are analogous to the "XXX" procedures, except that the result is returned in an array provided by the client (which must have the correct size). */ pz_symbol_chain_t *pz_symbol_chain_cut( pz_symbol_chain_t *c, int start, int length ); void pz_symbol_chain_do_cut( pz_symbol_chain_t *c, int start, int length, pz_symbol_chain_t *x ); /* Returns a new curve that is a copy of elements from "c[start]" to "c[start+length-1]". Assumes the curve is periodic, i.e. "c[i+n]==c[i]" for all "i", where "n==(c.ne)". */ void pz_symbol_chain_reverse_and_complement( pz_symbol_chain_t *c ); /* Reverses the curve back-to-front and negates all elements. */ pz_symbol_chain_t *pz_symbol_chain_extract_segment( pz_symbol_chain_t *c, pz_segment_t s ); void pz_symbol_chain_do_extract_segment( pz_symbol_chain_t *c, pz_segment_t s, pz_symbol_chain_t *x ); /* Extracts the given segment from the curvature graph "c", assumed to be closed. If "s.rev" is TRUE, also reverses and complements it. */ /* INPUT/OUTPUT */ void pz_symbol_chain_print_segment( FILE *wr, pz_symbol_chain_t *c, pz_segment_t s ); /* Prints to "wr" the segment "s" of the curve "c", reversed and complementd if "s.rev" is TRUE. */ void pz_symbol_chain_write( FILE *wr, char *cmt, pz_symbol_chain_t *c, double sigma ); /* Writes to "wr" a coded curvature curve "c", recording also the encoding parameter "sigma". */ typedef struct pz_symbol_chain_read_data { char *cmt; /* Comments */ int samples; /* Number of samples in curve. */ double sigma; /* Encoding parameter. */ pz_symbol_chain_t *c; /* Encoded curvature values. */ } pz_symbol_chain_read_data; pz_symbol_chain_read_data pz_symbol_chain_read( FILE *rd, bool_t header_only ); /* Reads a coded curvature curve and associated encoding parameters from "rd". If "header_only==TRUE", reads only the parameters, and leaves the "c" field as NULL. */ pz_symbol_chain_read_data pz_symbol_chain_read_old( FILE *rd, double sigma ); /* Reads from "rd" an old-format coded curvature curve, which was encoded with "pz_proc.OldSqueeze(epsilon, delta)", decodes it, and reencodes it with "pz_symbol_encode(x,sigma)". */ typedef struct pz_symbol_chain_read_all_data { pz_symbol_chain_read_data *chData; double sigmaMin; /* Minimum "sigma" value. */ double sigmaMax; /* Maximum "sigma" value. */ char *cmt; /* Comment of first curve, if any. */ } pz_symbol_chain_read_all_data; pz_symbol_chain_read_all_data pz_symbol_chain_read_all( char *prefix, int band, char *extension, bool_vec_t *sel, bool_t header_only, char *dir /* (:= ".") */ ); /* Reads a set of numbered curves, returns a "pz_symbol_chain_read_all_data" record "r". Curve number "i" is read if and only if "sel[i] == TRUE", and its "pz_symbol_chain_read_data" is stored in "r.curve[i]". If "sel[i] == FALSE", or the file is not found, "r.curve[i] " is set to a record with null "c" field. If "header_only" is TRUE, only the header of each file is read; the "c" fields are all set to NULL. The data is read from file "DDD/KKKK/PPPBBBEEE", where "DDD" is the directory "dir", "KKKK" is the curve number "k" (4 digits, zero padded), "PPP" is the prefix, "BBB" is the "band" number (3 digits, zero padded), and "eee" is the given "extension". The range of "sigma" parameters of the curves that were read is returned in "r.sigmaMin", "r.sigmaMax". The comment of the first curve read, plus the call arguments, are stored in "r.cmt". */ /* 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. */ #endif