PixFilt.h

00001 # ifndef PixFilt_h
00002 # define PixFilt_h PixFilt_h
00003 
00004 // ####################################################################
00005 // # Conjecture: An Extensible Optical Character Recognition Framework  #
00006 // #                                                                  #
00007 // # Copyright: Lesser GNU Public License (LGPL)                      #
00008 // #                                                                  #
00009 // # Overview:                                                        #
00010 // #  - Conjecture is a collection of C++ classes, and an OCR engine    #
00011 // #  - Conjecture is designed to allow customization at all levels     #
00012 // #    and to encourage individuals to contribute incremental        #
00013 // #    improvements in algorithms.                                   #
00014 // #  - Overall design discussions can be found in                    #
00015 // #      $SNROOT/docs/doxygen/html/index.html                        #
00016 // #  - Conjecture is designed to interact with and build on other      #
00017 // #    open-source OCR programs.                                     #
00018 // ####################################################################
00019 
00020 # include "Root.h"  // parent
00021 # include <vector>
00022 
00023 namespace Conjecture {
00024     class OptIm;
00025     
00026     // ##################################################################
00078 
00079     // ##################################################################
00080     class PixFilt : public Root {
00081       public:
00082         // Constructors/Destructors
00083         PixFilt(u1 yoffset);
00084         PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1);
00085         PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1, u1 mask2, int offset2);
00086         PixFilt::PixFilt(u1 yoffset, u1 mask1, int offset1, u1 mask2, int offset2, u1 mask3, int offset3);
00087         
00088         // **************
00089         // Accessors
00090         inline const u2*       data()    const { return this->_data;    }
00091         inline const u1 &      rows()    const { return this->_rows;    }
00092         inline const u1 &      yoffset() const { return this->_yoffset; }
00093         
00094         // **************
00095         // Input/Output
00096         
00097         // **************
00098         // Interface
00099         void add(u1 mask, int offset);
00100 
00101         std::string str() const;
00102 
00103         u1 mask(u1 index)    const { return ((this->_data[index]) >> 8);       }
00104         int offset(u1 index) const { return ((this->_data[index] >> 4)&0xf)-8; }
00105         u1 size(u1 index)    const { return ((this->_data[index]) & 0xf);      }
00106 
00108         bool match(const std::vector<u4>& rows, u1 width, u1 x, u1 y);
00109         bool match(const OptIm& im, u1 x, u1 y);
00110 
00117         int filter(std::vector<u4>& im, u1 width, bool set = true);
00118         int filter(OptIm& im, bool set = true);
00119 
00120         static void test(int argc = 0, const char* argv[] = NULL);
00121         
00122       protected:
00123         // **************
00124         // Accessors
00125         inline void rowsIs(const u1 & rows)       { this->_rows = rows; }
00126         inline void yoffsetIs(const u1 & yoffset) { this->_yoffset = yoffset; }
00127         
00128         // **************
00129         // Methods 
00130 
00137         static int ffs(u1 val);
00138         
00139       private: 
00140         // **************
00141         // Accessors
00142         inline u1  &  rowsRef()    { return this->_rows;    }
00143         inline u1  &  yoffsetRef() { return this->_yoffset; }
00144         
00145         // **************
00146         // Methods 
00147         
00148         // **************
00149         // State
00150 
00152         u1              _rows;
00153 
00156         u1              _yoffset;
00157 
00164         u2              _data[8];
00165     };
00166 }
00167 
00168 # endif // PixFilt_h
00169 

Generated on Wed Jun 14 15:08:02 2006 for Conjecture by  doxygen 1.4.6