feats_test1.cc (ocrad-0.24) | : | feats_test1.cc (ocrad-0.25) | ||
---|---|---|---|---|
/* GNU Ocrad - Optical Character Recognition program | /* GNU Ocrad - Optical Character Recognition program | |||
Copyright (C) 2003-2014 Antonio Diaz Diaz. | Copyright (C) 2003-2015 Antonio Diaz Diaz. | |||
This program is free software: you can redistribute it and/or modify | This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation, either version 2 of the License, or | the Free Software Foundation, either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | GNU General Public License for more details. | |||
skipping to change at line 116 | skipping to change at line 116 | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
int Features::test_4ADQao( const Charset & charset, const Rectangle & charbox ) const | int Features::test_4ADQao( const Charset & charset, const Rectangle & charbox ) const | |||
{ | { | |||
const Bitmap & h = b.hole( 0 ); | const Bitmap & h = b.hole( 0 ); | |||
int left_delta = h.left() - b.left(), right_delta = b.right() - h.right(); | int left_delta = h.left() - b.left(), right_delta = b.right() - h.right(); | |||
if( !lp.ispit() && lp.isflats() && rp.ispit() ) return 'D'; | if( !lp.ispit() && lp.isflats() && rp.ispit() ) return 'D'; | |||
if( !rp.isconvex() ) | if( Ocrad::similar( left_delta, right_delta, 40 ) && | |||
tp.minima() == 2 && bp.minima() == 2 && !rp.isconvex() ) return '#'; | ||||
if( tp.minima() == 1 && bp.minima() == 1 ) | ||||
{ | { | |||
if( Ocrad::similar( left_delta, right_delta, 40 ) && | int row = b.seek_bottom( h.bottom(), h.hcenter(), false ); | |||
tp.minima() == 2 && bp.minima() == 2 ) return '#'; | if( charset.enabled( Charset::iso_8859_15 ) || | |||
if( tp.minima() == 1 && bp.minima() == 1 ) | charset.enabled( Charset::iso_8859_9 ) ) | |||
{ | if( !lp.isconvex() && bp.isconvex() && !rp.isconvex() && | |||
int row = b.seek_bottom( h.bottom(), h.hcenter(), false ); | b.seek_bottom( row, h.hcenter() ) < b.bottom() ) | |||
if( charset.enabled( Charset::iso_8859_15 ) || | return UCS::SEACUTE; | |||
charset.enabled( Charset::iso_8859_9 ) ) | row = ( row + b.seek_bottom( row, h.hcenter() ) ) / 2; | |||
if( !lp.isconvex() && bp.isconvex() && | if( row < b.bottom() - 1 && !lp.isflats() && | |||
b.seek_bottom( row, h.hcenter() ) < b.bottom() ) | b.seek_left( row, h.hcenter() ) <= b.left() ) | |||
return UCS::SEACUTE; | { | |||
row = ( row + b.seek_bottom( row, h.hcenter() ) ) / 2; | if( ( 2 * h.height() <= b.height() || 2 * h.width() <= b.width() ) && | |||
if( row < b.bottom() - 1 && !lp.isflats() && | wp[h.top()-b.top()] < wp[h.bottom()-b.top()] ) return '4'; | |||
b.seek_left( row, h.hcenter() ) <= b.left() ) | if( !rp.ispit() && !rp.isconvex() ) return 'Q'; | |||
{ | ||||
if( wp[h.top()-b.top()] < wp[h.bottom()-b.top()] ) return '4'; | ||||
return 'Q'; | ||||
} | ||||
} | ||||
if( 2 * b.width() > 5 * h.width() ) | ||||
{ | ||||
const int c = segments_in_row( h.vcenter() ); | ||||
const int m = bp.minima(); | ||||
if( c == 3 && h.top() < b.vcenter() && h.bottom() > b.vcenter() && | ||||
3 * h.height() >= b.height() && ( m == 3 || m == 2 ) && !lp.ispit() ) | ||||
return 'm'; | ||||
if( c == 3 && left_delta > right_delta && lp.ispit() && | ||||
segments_in_col( h.hcenter() ) == 4 ) | ||||
return '@'; | ||||
if( c == 4 && Ocrad::similar( left_delta, right_delta, 40 ) && lp.ispit() | ||||
) | ||||
return '@'; | ||||
} | } | |||
} | } | |||
if( 2 * b.width() > 5 * h.width() && !rp.isconvex() ) | ||||
{ | ||||
const int c = segments_in_row( h.vcenter() ); | ||||
const int m = bp.minima(); | ||||
if( c == 3 && h.top() < b.vcenter() && h.bottom() > b.vcenter() && | ||||
3 * h.height() >= b.height() && ( m == 3 || m == 2 ) && !lp.ispit() ) | ||||
return 'm'; | ||||
if( c == 3 && left_delta > right_delta && lp.ispit() && | ||||
segments_in_col( h.hcenter() ) == 4 ) | ||||
return '@'; | ||||
if( c == 4 && Ocrad::similar( left_delta, right_delta, 40 ) && lp.ispit() ) | ||||
return '@'; | ||||
} | ||||
if( tp.minima() == 1 && bp.istip() && !rp.isctip( 66 ) ) return 'A'; | if( tp.minima() == 1 && bp.istip() && !rp.isctip( 66 ) ) return 'A'; | |||
if( Ocrad::similar( left_delta, right_delta, 50 ) ) | if( Ocrad::similar( left_delta, right_delta, 50 ) ) | |||
{ | { | |||
if( bp.minima() == 1 && rp.isconvex() && b.test_BD() ) return 'D'; | if( bp.minima() == 1 && rp.isconvex() && b.test_BD() ) return 'D'; | |||
if( bp.minima() > 1 || rp.minima() > 1 || b.test_Q() ) | if( bp.minima() > 1 || rp.minima() > 1 || b.test_Q() ) | |||
{ if( 4 * h.size() >= b.size() || tp.ispit() || lp.ispit() ) return 'Q'; | { if( 4 * h.size() >= b.size() || tp.ispit() || lp.ispit() ) return 'Q'; | |||
else return 0; } | else return 0; } | |||
if( 3 * bp[bp.pos(100)] < b.height() && 5 * rp[rp.pos(55)] >= b.width() ) | if( 3 * bp[bp.pos(100)] < b.height() && 5 * rp[rp.pos(55)] >= b.width() ) | |||
return 'a'; | return 'a'; | |||
if( lp.istip() ) return 'n'; | if( lp.istip() ) return 'n'; | |||
End of changes. 4 change blocks. | ||||
33 lines changed or deleted | 30 lines changed or added |