profile.cc (ocrad-0.24) | : | profile.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 506 | skipping to change at line 506 | |||
break; | break; | |||
} | } | |||
return false; | return false; | |||
} | } | |||
bool Profile::isltip() | bool Profile::isltip() | |||
{ | { | |||
if( limit_ < 0 ) initialize(); | if( limit_ < 0 ) initialize(); | |||
if( samples() < 5 ) return false; | if( samples() < 5 ) return false; | |||
const int noise = ( samples() / 30 ) + 1; | const int noise = ( samples() / 30 ) + 1; | |||
if( data[0] < noise + 1 ) return false; | if( data[0] <= noise ) return false; | |||
const int dmin = min(); | const int dmin = min(); | |||
int begin = 0, ref = limit_; | int begin = 0, ref = limit_; | |||
for( int i = 0; i < samples() - noise; ++i ) | for( int i = 0; i < samples() - noise; ++i ) | |||
{ | { | |||
int d = data[i]; | int d = data[i]; | |||
if( d == dmin ) { begin = i; break; } | if( d == dmin ) { begin = i; break; } | |||
if( d < ref ) ref = d; else if( d > ref + 1 ) return false; | if( d < ref ) ref = d; else if( d > ref + noise ) return false; | |||
} | } | |||
if( begin < 2 || 2 * begin > samples() ) return false; | if( begin <= noise || 2 * begin > samples() ) return false; | |||
return true; | ||||
} | ||||
bool Profile::isrtip() | ||||
{ | ||||
if( limit_ < 0 ) initialize(); | ||||
if( samples() < 5 ) return false; | ||||
const int noise = ( samples() / 30 ) + 1; | ||||
if( data[samples()-1] <= noise ) return false; | ||||
const int dmin = min(); | ||||
int begin = 0, ref = limit_; | ||||
for( int i = samples() - 1; i >= noise; --i ) | ||||
{ | ||||
int d = data[i]; | ||||
if( d == dmin ) { begin = samples() - 1 - i; break; } | ||||
if( d < ref ) ref = d; else if( d > ref + noise ) return false; | ||||
} | ||||
if( begin <= noise || 2 * begin > samples() ) return false; | ||||
return true; | return true; | |||
} | } | |||
int Profile::imaximum() | int Profile::imaximum() | |||
{ | { | |||
if( limit_ < 0 ) initialize(); | if( limit_ < 0 ) initialize(); | |||
const int margin = ( samples() / 30 ) + 1; | const int margin = ( samples() / 30 ) + 1; | |||
int mbegin = 0, mend, mvalue = 0; | int mbegin = 0, mend, mvalue = 0; | |||
for( int i = margin; i < samples() - margin; ++i ) | for( int i = margin; i < samples() - margin; ++i ) | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 23 lines changed or added |