grp4comp.c

来自「NIST Handwriting OCR Testbed」· C语言 代码 · 共 1,421 行 · 第 1/4 页

C
1,421
字号
				******************************************************************************/void write_run_length(length, color)SHORT length;SHORT color;{SHORT	multiples_of_largest_code,					make_up_code_index,			remainder,		i;				multiples_of_largest_code = length / Largest_code;	length %= Largest_code;	for(i=0 ; i < multiples_of_largest_code ; i++) 	    write_bits_c( largest_colorless_code );	remainder = length % Size_of_make_up_code_increments;	   /* remainder in the range 0 - 63 */   	make_up_code_index = length / Size_of_make_up_code_increments;	   /*    * make_up_code_index in the range 0 - 39, and represents a run length     * of 64 times its value (i.e. 0 - 2496).  To translate this value into    * an index into the arrays that store the bit sequence that represents    * the appropriate run length, 1 must be subtracted from make_up_code_    * index.  If this results in the value -1, no make up code should be    * written.    */    	make_up_code_index--;		if(make_up_code_index != Invalid) {	   if(color == White)	      write_bits_c(white_make_up_code[make_up_code_index]);	   else	      write_bits_c(black_make_up_code[make_up_code_index]);	}		if(color == White)	   write_bits_c(white_terminating_code[remainder]);	else	   write_bits_c(black_terminating_code[remainder]);} 	/* end write run length() *//***************************************************************************//* Originally table.c                                                      *//***************************************************************************/struct byte_descriptor {    SHORT pixel[9]; };        static struct byte_descriptor table[Number_of_different_bytes] ={       -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    5,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    5,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,    5,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    5,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    4,    5,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    4,    5,    7,   -1,   -1,   -1,   -1,   -1,   -1,    4,    5,    6,    7,   -1,   -1,   -1,   -1,   -1,    4,    5,    6,   -1,   -1,   -1,   -1,   -1,   -1,    4,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    4,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,    4,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    4,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    3,    4,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    3,    4,    7,   -1,   -1,   -1,   -1,   -1,   -1,    3,    4,    6,    7,   -1,   -1,   -1,   -1,   -1,    3,    4,    6,   -1,   -1,   -1,   -1,   -1,   -1,    3,    4,    5,    6,   -1,   -1,   -1,   -1,   -1,    3,    4,    5,    6,    7,   -1,   -1,   -1,   -1,    3,    4,    5,    7,   -1,   -1,   -1,   -1,   -1,    3,    4,    5,   -1,   -1,   -1,   -1,   -1,   -1,    3,    5,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    3,    5,    7,   -1,   -1,   -1,   -1,   -1,   -1,    3,    5,    6,    7,   -1,   -1,   -1,   -1,   -1,    3,    5,    6,   -1,   -1,   -1,   -1,   -1,   -1,    3,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    3,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,    3,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    3,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    2,    3,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    2,    3,    7,   -1,   -1,   -1,   -1,   -1,   -1,    2,    3,    6,    7,   -1,   -1,   -1,   -1,   -1,    2,    3,    6,   -1,   -1,   -1,   -1,   -1,   -1,    2,    3,    5,    6,   -1,   -1,   -1,   -1,   -1,    2,    3,    5,    6,    7,   -1,   -1,   -1,   -1,    2,    3,    5,    7,   -1,   -1,   -1,   -1,   -1,    2,    3,    5,   -1,   -1,   -1,   -1,   -1,   -1,    2,    3,    4,    5,   -1,   -1,   -1,   -1,   -1,    2,    3,    4,    5,    7,   -1,   -1,   -1,   -1,    2,    3,    4,    5,    6,    7,   -1,   -1,   -1,    2,    3,    4,    5,    6,   -1,   -1,   -1,   -1,    2,    3,    4,    6,   -1,   -1,   -1,   -1,   -1,    2,    3,    4,    6,    7,   -1,   -1,   -1,   -1,    2,    3,    4,    7,   -1,   -1,   -1,   -1,   -1,    2,    3,    4,   -1,   -1,   -1,   -1,   -1,   -1,    2,    4,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    2,    4,    7,   -1,   -1,   -1,   -1,   -1,   -1,    2,    4,    6,    7,   -1,   -1,   -1,   -1,   -1,    2,    4,    6,   -1,   -1,   -1,   -1,   -1,   -1,    2,    4,    5,    6,   -1,   -1,   -1,   -1,   -1,    2,    4,    5,    6,    7,   -1,   -1,   -1,   -1,    2,    4,    5,    7,   -1,   -1,   -1,   -1,   -1,    2,    4,    5,   -1,   -1,   -1,   -1,   -1,   -1,    2,    5,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    2,    5,    7,   -1,   -1,   -1,   -1,   -1,   -1,    2,    5,    6,    7,   -1,   -1,   -1,   -1,   -1,    2,    5,    6,   -1,   -1,   -1,   -1,   -1,   -1,    2,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    2,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,    2,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    2,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,    2,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,    2,    7,   -1,   -1,   -1,   -1,   -1,   -1,    1,    2,    6,    7,   -1,   -1,   -1,   -1,   -1,    1,    2,    6,   -1,   -1,   -1,   -1,   -1,   -1,    1,    2,    5,    6,   -1,   -1,   -1,   -1,   -1,    1,    2,    5,    6,    7,   -1,   -1,   -1,   -1,    1,    2,    5,    7,   -1,   -1,   -1,   -1,   -1,    1,    2,    5,   -1,   -1,   -1,   -1,   -1,   -1,    1,    2,    4,    5,   -1,   -1,   -1,   -1,   -1,    1,    2,    4,    5,    7,   -1,   -1,   -1,   -1,    1,    2,    4,    5,    6,    7,   -1,   -1,   -1,    1,    2,    4,    5,    6,   -1,   -1,   -1,   -1,    1,    2,    4,    6,   -1,   -1,   -1,   -1,   -1,    1,    2,    4,    6,    7,   -1,   -1,   -1,   -1,    1,    2,    4,    7,   -1,   -1,   -1,   -1,   -1,    1,    2,    4,   -1,   -1,   -1,   -1,   -1,   -1,    1,    2,    3,    4,   -1,   -1,   -1,   -1,   -1,    1,    2,    3,    4,    7,   -1,   -1,   -1,   -1,    1,    2,    3,    4,    6,    7,   -1,   -1,   -1,    1,    2,    3,    4,    6,   -1,   -1,   -1,   -1,    1,    2,    3,    4,    5,    6,   -1,   -1,   -1,    1,    2,    3,    4,    5,    6,    7,   -1,   -1,    1,    2,    3,    4,    5,    7,   -1,   -1,   -1,    1,    2,    3,    4,    5,   -1,   -1,   -1,   -1,    1,    2,    3,    5,   -1,   -1,   -1,   -1,   -1,    1,    2,    3,    5,    7,   -1,   -1,   -1,   -1,    1,    2,    3,    5,    6,    7,   -1,   -1,   -1,    1,    2,    3,    5,    6,   -1,   -1,   -1,   -1,    1,    2,    3,    6,   -1,   -1,   -1,   -1,   -1,    1,    2,    3,    6,    7,   -1,   -1,   -1,   -1,    1,    2,    3,    7,   -1,   -1,   -1,   -1,   -1,    1,    2,    3,   -1,   -1,   -1,   -1,   -1,   -1,    1,    3,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,    3,    7,   -1,   -1,   -1,   -1,   -1,   -1,    1,    3,    6,    7,   -1,   -1,   -1,   -1,   -1,    1,    3,    6,   -1,   -1,   -1,   -1,   -1,   -1,    1,    3,    5,    6,   -1,   -1,   -1,   -1,   -1,    1,    3,    5,    6,    7,   -1,   -1,   -1,   -1,    1,    3,    5,    7,   -1,   -1,   -1,   -1,   -1,    1,    3,    5,   -1,   -1,   -1,   -1,   -1,   -1,    1,    3,    4,    5,   -1,   -1,   -1,   -1,   -1,    1,    3,    4,    5,    7,   -1,   -1,   -1,   -1,    1,    3,    4,    5,    6,    7,   -1,   -1,   -1,    1,    3,    4,    5,    6,   -1,   -1,   -1,   -1,    1,    3,    4,    6,   -1,   -1,   -1,   -1,   -1,    1,    3,    4,    6,    7,   -1,   -1,   -1,   -1,    1,    3,    4,    7,   -1,   -1,   -1,   -1,   -1,    1,    3,    4,   -1,   -1,   -1,   -1,   -1,   -1,    1,    4,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,    4,    7,   -1,   -1,   -1,   -1,   -1,   -1,    1,    4,    6,    7,   -1,   -1,   -1,   -1,   -1,    1,    4,    6,   -1,   -1,   -1,   -1,   -1,   -1,    1,    4,    5,    6,   -1,   -1,   -1,   -1,   -1,    1,    4,    5,    6,    7,   -1,   -1,   -1,   -1,    1,    4,    5,    7,   -1,   -1,   -1,   -1,   -1,    1,    4,    5,   -1,   -1,   -1,   -1,   -1,   -1,    1,    5,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,    5,    7,   -1,   -1,   -1,   -1,   -1,   -1,    1,    5,    6,    7,   -1,   -1,   -1,   -1,   -1,    1,    5,    6,   -1,   -1,   -1,   -1,   -1,   -1,    1,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,    1,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,    7,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,    6,    7,   -1,   -1,   -1,   -1,   -1,    0,    1,    6,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,    5,    6,   -1,   -1,   -1,   -1,   -1,    0,    1,    5,    6,    7,   -1,   -1,   -1,   -1,    0,    1,    5,    7,   -1,   -1,   -1,   -1,   -1,    0,    1,    5,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,    4,    5,   -1,   -1,   -1,   -1,   -1,    0,    1,    4,    5,    7,   -1,   -1,   -1,   -1,    0,    1,    4,    5,    6,    7,   -1,   -1,   -1,    0,    1,    4,    5,    6,   -1,   -1,   -1,   -1,    0,    1,    4,    6,   -1,   -1,   -1,   -1,   -1,    0,    1,    4,    6,    7,   -1,   -1,   -1,   -1,    0,    1,    4,    7,   -1,   -1,   -1,   -1,   -1,    0,    1,    4,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,    3,    4,   -1,   -1,   -1,   -1,   -1,    0,    1,    3,    4,    7,   -1,   -1,   -1,   -1,    0,    1,    3,    4,    6,    7,   -1,   -1,   -1,    0,    1,    3,    4,    6,   -1,   -1,   -1,   -1,    0,    1,    3,    4,    5,    6,   -1,   -1,   -1,    0,    1,    3,    4,    5,    6,    7,   -1,   -1,    0,    1,    3,    4,    5,    7,   -1,   -1,   -1,    0,    1,    3,    4,    5,   -1,   -1,   -1,   -1,    0,    1,    3,    5,   -1,   -1,   -1,   -1,   -1,    0,    1,    3,    5,    7,   -1,   -1,   -1,   -1,    0,    1,    3,    5,    6,    7,   -1,   -1,   -1,    0,    1,    3,    5,    6,   -1,   -1,   -1,   -1,    0,    1,    3,    6,   -1,   -1,   -1,   -1,   -1,    0,    1,    3,    6,    7,   -1,   -1,   -1,   -1,    0,    1,    3,    7,   -1,   -1,   -1,   -1,   -1,    0,    1,    3,   -1,   -1,   -1,   -1,   -1,   -1,    0,    1,    2,    3,   -1,   -1,   -1,   -1,   -1,    0,    1,    2,    3,    7,   -1,   -1,   -1,   -1,    0,    1,    2,    3,    6,    7,   -1,   -1,   -1,    0,    1,    2,    3,    6,   -1,   -1,   -1,   -1,    0,    1,    2,    3,    5,    6,   -1,   -1,   -1,    0,    1,    2,    3,    5,    6,    7,   -1,   -1,    0,    1,    2,    3,    5,    7,   -1,   -1,   -1,    0,    1,    2,    3,    5,   -1,   -1,   -1,   -1,    0,    1,    2,    3,    4,    5,   -1,   -1,   -1,    0,    1,    2,    3,    4,    5,    7,   -1,   -1,    0,    1,    2,    3,    4,    5,    6,    7,   -1,    0,    1,    2,    3,    4,    5,    6,   -1,   -1,    0,    1,    2,    3,    4,    6,   -1,   -1,   -1,    0,    1,    2,    3,    4,    6,    7,   -1,   -1,    0,    1,    2,    3,    4,    7,   -1,   -1,   -1,    0,    1,    2,    3,    4,   -1,   -1,   -1,   -1,    0,    1,    2,    4,   -1,   -1,   -1,   -1,   -1,    0,    1,    2,    4,    7,   -1,   -1,   -1,   -1,    0,    1,    2,    4,    6,    7,   -1,   -1,   -1,    0,    1,    2,    4,    6,   -1,   -1,   -1,   -1,    0,    1,    2,    4,    5,    6,   -1,   -1,   -1,    0,    1,    2,    4,    5,    6,    7,   -1,   -1,    0,    1,    2,    4,    5,    7,   -1,   -1,   -1,    0,    1,    2,    4,    5,   -1,   -1,   -1,   -1,    0,    1,    2,    5,   -1,   -1,   -1,   -1,   -1,    0,    1,    2,    5,    7,   -1,   -1,   -1,   -1,    0,    1,    2,    5,    6,    7,   -1,   -1,   -1,    0,    1,    2,    5,    6,   -1,   -1,   -1,   -1,    0,    1,    2,    6,   -1,   -1,   -1,   -1,   -1,    0,    1,    2,    6,    7,   -1,   -1,   -1,   -1,    0,    1,    2,    7,   -1,   -1,   -1,   -1,   -1,    0,    1,    2,   -1,   -1,   -1,   -1,   -1,   -1,    0,    2,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    2,    7,   -1,   -1,   -1,   -1,   -1,   -1,    0,    2,    6,    7,   -1,   -1,   -1,   -1,   -1,    0,    2,    6,   -1,   -1,   -1,   -1,   -1,   -1,    0,    2,    5,    6,   -1,   -1,   -1,   -1,   -1,    0,    2,    5,    6,    7,   -1,   -1,   -1,   -1,    0,    2,    5,    7,   -1,   -1,   -1,   -1,   -1,    0,    2,    5,   -1,   -1,   -1,   -1,   -1,   -1,    0,    2,    4,    5,   -1,   -1,   -1,   -1,   -1,    0,    2,    4,    5,    7,   -1,   -1,   -1,   -1,    0,    2,    4,    5,    6,    7,   -1,   -1,   -1,    0,    2,    4,    5,    6,   -1,   -1,   -1,   -1,    0,    2,    4,    6,   -1,   -1,   -1,   -1,   -1,    0,    2,    4,    6,    7,   -1,   -1,   -1,   -1,    0,    2,    4,    7,   -1,   -1,   -1,   -1,   -1,    0,    2,    4,   -1,   -1,   -1,   -1,   -1,   -1,    0,    2,    3,    4,   -1,   -1,   -1,   -1,   -1,    0,    2,    3,    4,    7,   -1,   -1,   -1,   -1,    0,    2,    3,    4,    6,    7,   -1,   -1,   -1,    0,    2,    3,    4,    6,   -1,   -1,   -1,   -1,    0,    2,    3,    4,    5,    6,   -1,   -1,   -1,    0,    2,    3,    4,    5,    6,    7,   -1,   -1,    0,    2,    3,    4,    5,    7,   -1,   -1,   -1,    0,    2,    3,    4,    5,   -1,   -1,   -1,   -1,    0,    2,    3,    5,   -1,   -1,   -1,   -1,   -1,    0,    2,    3,    5,    7,   -1,   -1,   -1,   -1,    0,    2,    3,    5,    6,    7,   -1,   -1,   -1,    0,    2,    3,    5,    6,   -1,   -1,   -1,   -1,    0,    2,    3,    6,   -1,   -1,   -1,   -1,   -1,    0,    2,    3,    6,    7,   -1,   -1,   -1,   -1,    0,    2,    3,    7,   -1,   -1,   -1,   -1,   -1,    0,    2,    3,   -1,   -1,   -1,   -1,   -1,   -1,    0,    3,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    3,    7,   -1,   -1,   -1,   -1,   -1,   -1,    0,    3,    6,    7,   -1,   -1,   -1,   -1,   -1,    0,    3,    6,   -1,   -1,   -1,   -1,   -1,   -1,    0,    3,    5,    6,   -1,   -1,   -1,   -1,   -1,    0,    3,    5,    6,    7,   -1,   -1,   -1,   -1,    0,    3,    5,    7,   -1,   -1,   -1,   -1,   -1,    0,    3,    5,   -1,   -1,   -1,   -1,   -1,   -1,    0,    3,    4,    5,   -1,   -1,   -1,   -1,   -1,    0,    3,    4,    5,    7,   -1,   -1,   -1,   -1,    0,    3,    4,    5,    6,    7,   -1,   -1,   -1,    0,    3,    4,    5,    6,   -1,   -1,   -1,   -1,    0,    3,    4,    6,   -1,   -1,   -1,   -1,   -1,    0,    3,    4,    6,    7,   -1,   -1,   -1,   -1,    0,    3,    4,    7,   -1,   -1,   -1,   -1,   -1,    0,    3,    4,   -1,   -1,   -1,   -1,   -1,   -1,    0,    4,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    4,    7,   -1,   -1,   -1,   -1,   -1,   -1,    0,    4,    6,    7,   -1,   -1,   -1,   -1,   -1,    0,    4,    6,   -1,   -1,   -1,   -1,   -1,   -1,    0,    4,    5,    6,   -1,   -1,   -1,   -1,   -1,    0,    4,    5,    6,    7,   -1,   -1,   -1,   -1,    0,    4,    5,    7,   -1,   -1,   -1,   -1,   -1,    0,    4,    5,   -1,   -1,   -1,   -1,   -1,   -1,    0,    5,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    5,    7,   -1,   -1,   -1,   -1,   -1,   -1,    0,    5,    6,    7,   -1,   -1,   -1,   -1,   -1,    0,    5,    6,   -1,   -1,   -1,   -1,   -1,   -1,    0,    6,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,    6,    7,   -1,   -1,   -1,   -1,   -1,   -1,    0,    7,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,}; /* end of data for list of byte descriptors */    /****************************** process_char *********************************	writes the pixel number of each changing element within the character	being processed to the list "params->coding_line"				******************************************************************************/void process_char( data_byte, params )unsigned char data_byte;struct parameters *params;{static char color = 0;SHORT i = 0;	color = -(data_byte & Last_bit_mask); 	data_byte ^= params->previous_color; 	/* if the previous color is black - which is contrary to our assumptions -* the bits in the byte must all be changed so that the result, when used* as an index into the array 'bytes,' yields the correct result.  In the* above operation, if the previous color is black (11111111b), all bits* are changed; if the previous color is white (00000000b), no bits are* changed. */		while(table[data_byte].pixel[i] != Invalid) 	      *( params->coding_line + ++params->index ) = 	      params->pixel + table[data_byte].pixel[i++];			params->pixel += Pixels_per_byte;	params->previous_color = color;		/* 'color' is a temporary holding place for the value of previous color */ }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?