1 /* GNU Ocrad - Optical Character Recognition program 2 Copyright (C) 2003-2019 Antonio Diaz Diaz. 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 class Blob : public Bitmap 19 { 20 std::vector< Bitmap * > holepv; // vector of holes 21 22 public: Blob(const int l,const int t,const int r,const int b)23 Blob( const int l, const int t, const int r, const int b ) 24 : Bitmap( l, t, r, b ) {} 25 Blob(const Bitmap & source,const Rectangle & re)26 Blob( const Bitmap & source, const Rectangle & re ) 27 : Bitmap( source, re ) {} 28 29 Blob( const Blob & b ); 30 Blob & operator=( const Blob & b ); 31 32 ~Blob(); 33 34 using Bitmap::left; 35 using Bitmap::top; 36 using Bitmap::right; 37 using Bitmap::bottom; 38 using Bitmap::height; 39 using Bitmap::width; 40 void left ( const int l ); 41 void top ( const int t ); 42 void right ( const int r ); 43 void bottom( const int b ); height(const int h)44 void height( const int h ) { bottom( top() + h - 1 ); } width(const int w)45 void width ( const int w ) { right( left() + w - 1 ); } 46 47 const Bitmap & hole( const int i ) const; holes()48 int holes() const { return holepv.size(); } 49 // id = 1 for blob dots, negative for hole dots, 0 otherwise 50 int id( const int row, const int col ) const; 51 is_abnormal()52 bool is_abnormal() const 53 { return height() < 10 || height() >= 5 * width() || width() >= 3 * height(); } 54 bool test_BD() const; 55 bool test_Q() const; 56 void print( FILE * const outfile ) const; 57 58 void fill_hole( const int i ); 59 void find_holes(); 60 }; 61