PixelLine32.h

00001 # ifndef PixelLine32_h
00002 # define PixelLine32_h PixelLine32_h
00003 
00004 // ####################################################################
00005 // # SomeName: An Extensible Optical Character Recognition Framework  #
00006 // #                                                                  #
00007 // # Copyright: Lesser GNU Public License (LGPL)                      #
00008 // #                                                                  #
00009 // # Overview:                                                        #
00010 // #  - SomeName is a collection of C++ classes, and an OCR engine    #
00011 // #  - SomeName 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 // #  - SomeName is designed to interact with and build on other      #
00017 // #    open-source OCR programs.                                     #
00018 // ####################################################################
00019 
00020 # include "Root.h"  // parent
00021 
00022 namespace SomeName {
00023     
00024     // ##################################################################
00031     // ##################################################################
00032     
00033     // IMPLEMENTATION NOTES:
00034     //   - this class is designed for highly efficient space utiliation,
00035     //     while also providing support for highly efficient feature
00036     //     analysis.
00037     //   - some "auxillary" methods are quite slow (i.e. 'set' and
00038     //     'clear' - this class is meant to be used primarily on
00039     //     frozen images, so setting and clearing bits is not a
00040     //     priority for efficient implementation.
00041     //   - does NOT store the size of the pixel line (assumed to be
00042     //     be maintained elsewhere). This implies that the number of
00043     //     white pixels cannot be reported without obtaining the size
00044     //     (#black is stored, and #white = total - #black).
00045     //   - not using setters internally in some situations because
00046     //     bit-specifiers cause temporaries to be used in returns
00047     // ##################################################################
00048     class PixelLine32 : public Root {
00049       public:
00050         static const u1 MaxPixels = 31;
00051 
00052         // Constructors/Destructors
00053         PixelLine32(u4 pixels);
00054         
00055         // **************
00056         // Accessors
00057         inline u1   holes()  const { return this->_holes;  }
00058         inline u4   pixels() const { return this->_pixels; }
00059         inline u1   black()  const { return this->_black;  }
00060         
00061         // **************
00062         // Input/Output
00063         
00064         // **************
00065         // Interface
00066 
00071         inline bool get(unsigned i) const {
00072             return (this->pixels() & (1<<i)) ? true : false;
00073         }
00074         
00081         void set(unsigned i);
00082         
00089         void clear(unsigned i);
00090         
00092         std::string str(char on = '#', char off = '.', u1 size = 31) const;
00093         
00094         static void test(int argc = 0, const char* argv[] = NULL);
00095         
00096       protected:
00097         // **************
00098         // Accessors
00099     inline void            blackIs(const u1 & black) { this->_black = black; }
00100         inline void            holesIs(const u1 & holes)   { this->_holes = holes; }
00101         inline void            pixelsIs(const u4 & pixels) { this->_pixels = pixels; }
00102         
00103         // **************
00104         // Methods 
00105         
00106       private: 
00107 
00108         // **************
00109         // Accessors
00110         
00111         // **************
00112         // Methods 
00113         void init(u4 p);
00114 
00115         // **************
00116         // State
00117 
00125         u4              _pixels;
00126 
00137         unsigned int    _holes:4;
00138 
00143         u1              _black:5;
00144 
00154     };
00155 }
00156 
00157 # endif // PixelLine32_h
00158 

Generated on Thu Jun 8 11:53:13 2006 for SomeName by  doxygen 1.4.6