Bitmap.h

00001 # ifndef SomeClass_Bitmap_h
00002 # define SomeClass_Bitmap_h SomeClass_Bitmap_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 // Class Champion: Bruno
00020 
00021 # include "Root.h"  // parent
00022 # include "Coord.h"
00023 # include "ImageFilter.h"
00024 
00025 namespace Conjecture {
00026 
00027     typedef unsigned char Pixel; // TODO: should this be a class?
00028 
00029     // ##################################################################
00035     // ##################################################################
00036     class Bitmap : public Root {
00037 
00038     public:
00039         // Constructors/Destructors
00040         Bitmap(uint32_t width, uint32_t height);
00041 
00042         Bitmap(const std::string &filename);
00043 
00044         ~Bitmap();
00045 
00046         // **************
00047         // Accessors
00048         inline const Pixel operator() (uint32_t x, uint32_t y) const {
00049             return ( (_pixels[at(x,y)] & (1 << (x & 0x07))) == 0 ? 0 : 1);
00050         }
00051 
00052         inline const Pixel mask(uint32_t x, uint32_t y) const {
00053             return ( (_mask[at(x,y)] & (1 << (x & 0x07))) == 0 ? 0 : 1);
00054         }
00055 
00056         inline const uint32_t width() const {
00057             return this->_width;
00058         }
00059 
00060         inline const uint32_t height() const {
00061             return this->_height;
00062         }
00063 
00064         // **************
00065         // Input/Output
00066 
00067         // **************
00068         // Interface
00069 
00073         Bitmap clone(void) const;
00074 
00082         const Bitmap clone(Coord a, Coord b) const;
00083 
00089         bool filter(ImageFilter &imfilter);
00090 
00097         static void test(int argc = 0, const char* argv[] = NULL);
00098 
00099     protected:
00100         // **************
00101         // Accessors
00102 
00103         // **************
00104         // Methods
00105 
00106     private:
00107         // **************
00108         // Accessors
00109 
00110         // **************
00111         // Methods
00112 
00119         inline uint32_t at(uint32_t x, uint32_t y) const {
00120             return (y * _linesize + (x >> 3));
00121         }
00122 
00123         // **************
00124         // State
00125 
00126         typedef uint32_t PixelBlock; // TODO: this should be platform dependent
00127 
00128         uint32_t        _width;
00129         uint32_t        _height;
00130         uint32_t        _linesize;
00131         PixelBlock      *_pixels;
00132         PixelBlock      *_mask;
00133 
00134     };
00135 }
00136 
00137 # endif // SomeClass_h
00138 

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