reference/ocr-new/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 
       
    19 class BitMap{
       
    20  public:
       
    21   friend MapStatus convertMap(RLEMap *,BitMap*,Point,Point);
       
    22   friend MapStatus convertMap(BitMap *,RLEMap*,Point,Point);
       
    23 
       
    24   BitMap();
       
    25 
       
    26   ~BitMap();
       
    27 
       
    28   int & imageLength() 
       
    29     {return fImageLength;};
       
    30 
       
    31   int & imageWidth()
       
    32     {return fImageWidth;};
       
    33 
       
    34   readBit(Point  p);
       
    35 
       
    36   MapStatus & status()
       
    37     {return fStatus; };
       
    38 
       
    39   uchar * row(int i);         // returns a pointer to row i
       
    40 
       
    41 
       
    42   // I/O operations.  readMap and writeMap are from/to 2 level TIFF files
       
    43 
       
    44   MapStatus readMap(char * filename);
       
    45   MapStatus writeMap(char * filename);   // not done
       
    46     
       
    47   // Write out BitMap format for TCL/TK display
       
    48   MapStatus writeTclMap(char * filename, Point  ul, Point  lr, int scaledown);
       
    49   // Detect skew Angle 
       
    50   Angle skewAngle();
       
    51  
       
    52   //Rotate the map designated angle.  
       
    53   MapStatus rotateMap(Angle angl); 
       
    54   
       
    55 
       
    56   // Return a ratio of black pixels to white pixels
       
    57   // scaled to 255 0 = all white 255=all black
       
    58   short int grayScale(Point  ul, Point  lr);
       
    59 
       
    60   // number of black pixels in bounding box
       
    61   const int BitMap::pixelsInRegion( Point ul, Point lr);
       
    62   int BitMap::minThickness(Point  ul,  Point  lr);
       
    63 private:
       
    64  
       
    65 
       
    66 	int fImageWidth;
       
    67 	int fImageLength;
       
    68 	MapStatus fStatus;
       
    69 	uchar ** fMapData;
       
    70 
       
    71 } ;
       
    72 
       
    73 
       
    74 
       
    75 #endif
       
    76 
       
    77 
       
    78