X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=pctb%2Fstructure.c;h=5a593887350025f8ce39c5e5d2a90e9c72df61e9;hp=a3cca0b4408fc3da115bd91f069589956c0fb0f7;hb=2ce6556e62248b0d82ae291badd5fbcc028ee0bc;hpb=9b746cc0a0512dd570aa5d4b6185bc1007f74b03 diff --git a/pctb/structure.c b/pctb/structure.c index a3cca0b..5a59388 100644 --- a/pctb/structure.c +++ b/pctb/structure.c @@ -496,11 +496,12 @@ static void find_table_entry(Rect commod, int colno, Rect *cell) { ((double)here_chan - (double)bg_chan) / ((double)fg_chan - (double)bg_chan); alpha[i]= alpha_chan; - alpha_mean += alpha_chan / 3; + alpha_mean += alpha_chan * (1/3.0); } - double alpha_min = alpha_mean - 0.13; - double alpha_max = alpha_mean + 0.13; + double thresh= 1.0/AAMAXVAL; + double alpha_min= alpha_mean - thresh; + double alpha_max= alpha_mean + thresh; for (i=0; i<3; i++) MUST( alpha_min <= alpha[i] && alpha[i] <= alpha_max, MI(i);MRGB(here);MRGB(background);MRGB(foreground); @@ -509,12 +510,12 @@ static void find_table_entry(Rect commod, int colno, Rect *cell) { MUST( 0 <= alpha_mean && alpha_mean <= 1, MRGB(here);MRGB(background);MRGB(foreground); MF(alpha_mean) ); - int here_int= 7*alpha_mean; - if (!(here_int==0 || here_int==7)) monochrome=0; + int here_int= AAMAXVAL*alpha_mean; + if (!(here_int==0 || here_int==AAMAXVAL)) monochrome=0; cim->d[p.y * cim->w + p.x]= '0' + here_int; } - debug_rect("cell07", colno, *cell); + debug_rect("cell0M", colno, *cell); require_rectangle_r(*cell, "0123456789", __LINE__); } @@ -531,9 +532,9 @@ static void ocr_rectangle(Rect r, const OcrCellType ct, FILE *tsv_output) { Point here= { x+r.tl.x, y+r.tl.y }; int pixel= get_p(here); switch (pixel) { - case ' ': break; - case '0': break; - case '7': cx |= rv; break; + case ' ': break; + case '0': break; + case '0'+AAMAXVAL: cx |= rv; break; default: MUST(!"wrong pixel", MC(pixel);MP(here);MSB(ocr_celltype_name(ct));MR(r); );