1
// test routines - faster to compile
8
// for learn_mode/analyze_mode high, with, yoffset, num of pattern_i,
9
// - holes (center,radius in relative coordinates) etc. => cluster analyze
10
// num_hole => min-volume, tolerance border
13
// regular filter for large resolutions to make edges more smooth (on boxes)
14
// extra-filter (only if not recognized?)
15
// map + same color to (#==change)
18
// strongest neighbour pixels (3x3) => directions
19
// second/third run with more and more tolerance!?
21
/* FIXME jb: following is unused */
23
struct lobj { // line-object (for fitting to near lines)
24
int x0,y0; // starting point (left up)
25
int x1,y1; // end point (right down)
26
int mt; // minimum thickness
27
int q; // quality, overlapp
34
// that is the first draft of feature extraction
35
// detect main lines and bows
36
// seems bad implemented, looking for better algorithms (ToDo: use autotrace)
38
void ocr2(pix *b,int cs){
39
int x1,y1,x2,y2,l,i,j,xa[MAXL],ya[MAXL],xb[MAXL],yb[MAXL],ll[MAXL];
40
for(i=0;i<MAXL;i++)xa[i]=ya[i]=xb[i]=yb[i]=ll[i]=0;
41
for(x1=0;x1<b->x;x1++) // very slowly, but simple to program
42
for(y1=0;y1<b->y;y1++) // brute force
43
for(x2=0;x2<b->x;x2++)
44
for(y2=y1+1;y2<b->y;y2++)
46
if( get_line2(x1,y1,x2,y2,b,cs,100)>99 )
48
l=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); // len
50
{ // remove similar lines (same middle point) IMPROVE IT !!!!!! ???
52
abs(x1+x2-xa[i]-xb[i])<1+b->x/2
53
&& abs(y1+y2-ya[i]-yb[i])<1+b->y/2
54
&& abs(y1-ya[i])<1+b->y/4
55
&& abs(x1-xa[i])<1+b->x/4
62
xa[j]=xa[j+1];ya[j]=ya[j+1];
63
xb[j]=xb[j+1];yb[j]=yb[j+1];ll[j]=ll[j+1];
67
else break; // forget it if shorter
69
if( l>ll[i] ){ // insert if larger
70
for(j=MAXL-1;j>i;j--){ // shift table
71
xa[j]=xa[j-1];ya[j]=ya[j-1];
72
xb[j]=xb[j-1];yb[j]=yb[j-1];ll[j]=ll[j-1];
74
xa[i]=x1;ya[i]=y1;xb[i]=x2;yb[i]=y2;ll[i]=l;
81
printf(" %2d %2d %2d %2d %3d\n",xa[i],ya[i],xb[i],yb[i],ll[i]);