"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "bitmap.cc" between
ocrad-0.24.tar.gz and ocrad-0.25.tar.gz

About: GNU Ocrad is an OCR (Optical Character Recognition) program.

bitmap.cc  (ocrad-0.24):bitmap.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 160 skipping to change at line 160
for( col2 = right(); col2 >= col1; --col2 ) for( col2 = right(); col2 >= col1; --col2 )
for( int row = top(); row <= bottom(); ++row ) for( int row = top(); row <= bottom(); ++row )
if( get_bit( row , col2) ) goto L2; if( get_bit( row , col2) ) goto L2;
L2: L2:
if( col1 >= col2 ) return false; if( col1 >= col2 ) return false;
if( col1 > left() ) left( col1 ); if( col1 > left() ) left( col1 );
if( col2 < right() ) right( col2 ); if( col2 < right() ) right( col2 );
return true; return true;
} }
// Return the total filled area of this Bitmap // Returns the total filled area of this Bitmap
// //
int Bitmap::area() const int Bitmap::area() const
{ {
int a = 0; int a = 0;
for( int row = top(); row <= bottom(); ++row ) for( int row = top(); row <= bottom(); ++row )
for( int col = left(); col <= right(); ++col ) for( int col = left(); col <= right(); ++col )
if( get_bit( row, col ) ) ++a; if( get_bit( row, col ) ) ++a;
return a; return a;
} }
// Return the central octagon filled area of this Bitmap // Returns the central octagon filled area of this Bitmap
// //
int Bitmap::area_octagon() const int Bitmap::area_octagon() const
{ {
int a = 0; int a = 0;
int bevel = ( 29 * std::min( height(), width() ) ) / 100; int bevel = ( 29 * std::min( height(), width() ) ) / 100;
int l = left() + bevel; int l = left() + bevel;
int r = right() - bevel; int r = right() - bevel;
for( int i = 0; i < bevel; ++i ) for( int i = 0; i < bevel; ++i )
for( int row = top() + i, col = l - i; col <= r + i; ++col ) for( int row = top() + i, col = l - i; col <= r + i; ++col )
skipping to change at line 197 skipping to change at line 197
for( int col = left(); col <= right(); ++col ) for( int col = left(); col <= right(); ++col )
if( get_bit( row, col ) ) ++a; if( get_bit( row, col ) ) ++a;
for( int i = bevel - 1; i >= 0; --i ) for( int i = bevel - 1; i >= 0; --i )
for( int row = bottom() - i, col = l - i; col <= r + i; ++col ) for( int row = bottom() - i, col = l - i; col <= r + i; ++col )
if( get_bit( row, col ) ) ++a; if( get_bit( row, col ) ) ++a;
return a; return a;
} }
// Return the size of the central octagon of this blob // Returns the size of the central octagon of this blob
// //
int Bitmap::size_octagon() const int Bitmap::size_octagon() const
{ {
int bevel = ( 29 * std::min( height(), width() ) ) / 100; int bevel = ( 29 * std::min( height(), width() ) ) / 100;
return size() - ( 2 * bevel * ( bevel + 1 ) ); return size() - ( 2 * bevel * ( bevel + 1 ) );
} }
int Bitmap::seek_left( const int row, const int col, const bool black ) const int Bitmap::seek_left( const int row, const int col, const bool black ) const
{ {
int c = col; int c = col;
skipping to change at line 276 skipping to change at line 276
bool Bitmap::escape_right( int row, int col ) const bool Bitmap::escape_right( int row, int col ) const
{ {
if( get_bit( row, col ) ) return false; if( get_bit( row, col ) ) return false;
int u, d; int u, d;
for( u = row; u > top() + 1; --u ) if( get_bit( u - 1, col ) ) break; for( u = row; u > top() + 1; --u ) if( get_bit( u - 1, col ) ) break;
for( d = row; d < bottom() - 1; ++d ) if( get_bit( d + 1, col ) ) break; for( d = row; d < bottom() - 1; ++d ) if( get_bit( d + 1, col ) ) break;
while( u <= d && ++col <= right() ) while( u <= d && ++col <= right() )
{ {
if( u > top() + 1 && !get_bit( u, col ) ) --u; while( u > top() + 1 && !get_bit( u, col ) ) --u;
if( d < bottom() - 1 && !get_bit( d, col ) ) ++d; while( d < bottom() - 1 && !get_bit( d, col ) ) ++d;
while( u <= d && get_bit( u, col ) ) ++u; while( u <= d && get_bit( u, col ) ) ++u;
while( u <= d && get_bit( d, col ) ) --d; while( u <= d && get_bit( d, col ) ) --d;
} }
return ( col > right() ); return ( col > right() );
} }
bool Bitmap::escape_bottom( int row, int col ) const bool Bitmap::escape_bottom( int row, int col ) const
{ {
if( get_bit( row, col ) ) return false; if( get_bit( row, col ) ) return false;
int l, r; int l, r;
 End of changes. 5 change blocks. 
6 lines changed or deleted 6 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS