reference/ocr-simple/BitMap.h
changeset 0 6b8091ca909a
equal deleted inserted replaced
-1:000000000000 0:6b8091ca909a
       
     1 #ifndef _BITMAP_H
       
     2 #define _BITMAP_H
       
     3 #include "system.h"
       
     4 
       
     5 /** A BitMap representation stores image in an array of unsigned character
       
     6     arrays.  There is one uchar array per row.  Each bit of the uchar 
       
     7     represents a pixel.
       
     8 ***/
       
     9 
       
    10 
       
    11 class RLEMap;
       
    12 class Point;
       
    13 class BitMap;
       
    14 
       
    15 extern void byteprint(char d);
       
    16 extern void bitprint(char d, int x);
       
    17 
       
    18 class BitMap{
       
    19  public:
       
    20   friend MapStatus convertMap(RLEMap *,BitMap*,Point,Point);
       
    21   BitMap();
       
    22 
       
    23   ~BitMap();
       
    24 
       
    25   int & imageLength() 
       
    26     {return fImageLength;};
       
    27 
       
    28   int & imageWidth()
       
    29     {return fImageWidth;};
       
    30 
       
    31   MapStatus & status()
       
    32     {return fStatus; };
       
    33 
       
    34   uchar * row(int i);         // returns a pointer to row i
       
    35 
       
    36 
       
    37   // I/O operations.  readMap and writeMap are from/to 2 level TIFF files
       
    38 
       
    39   MapStatus readMap(char * filename);
       
    40   MapStatus writeMap(char * filename);   // not done
       
    41     
       
    42   // Write out BitMap format for TCL/TK display
       
    43   MapStatus writeTclMap(char * filename, Point & ul, Point & lr, int scaledown);
       
    44   // Detect skew Angle 
       
    45   Angle skewAngle();
       
    46  
       
    47   //Rotate the map designated angle.  
       
    48   MapStatus rotateMap(Angle angl); 
       
    49   
       
    50 
       
    51   // Return a ratio of black pixels to white pixels
       
    52   // scaled to 255 0 = all white 255=all black
       
    53   short int grayScale(Point & ul, Point & lr);
       
    54 
       
    55   // number of black pixels in bounding box
       
    56   int BitMap::pixelsInRegion(Point  ul, Point lr);
       
    57 
       
    58 private:
       
    59  
       
    60 
       
    61 	int fImageWidth;
       
    62 	int fImageLength;
       
    63 	MapStatus fStatus;
       
    64 	uchar ** fMapData;
       
    65 
       
    66 } ;
       
    67 
       
    68 
       
    69 
       
    70 #endif