reference/ocr-simple/RLEMap.h
author viric@llimona
Thu, 18 May 2006 23:12:51 +0200
changeset 0 6b8091ca909a
permissions -rw-r--r--
Init from working directory of svn repository.

#ifndef _RLEMap_H
#define _RLEMap_H
#include "system.h"
#include "RLEPair.h"
#include <math.h>



/* The RLEMap Class is a run length encoded representation of a bitmap
   The I/O functions defined for this class read and write data from 
   TIFF format files using the Silicon Graphics TIFF library.

*/

class RLEMap{
	public:

	// Constructor, Destructor and copy functions
      	RLEMap();
       ~RLEMap();

	// Selector and Modifier functions

	int & imageLength();
	int & imageWidth();
	inline int pixels_between(int start, int finish, int row_num){
	  return fMapData[row_num]->pixelsBetween(start, finish);
	};

	MapStatus & status();
	
	void display_intervals(char* color);

	ListElement* FindNearHorizDot(int startCol, int startRow, int endRow);
	ListElement* FindNearVertDot(int startCol, int endCol, 
				     int startRow, int endRow);

	// I/O operations.  Read and Write are from/to 2 level TIFF files

	  MapStatus readMap(char * filename);
	MapStatus writeMap(char * filename);

	// Data Access and low level manipulation functions  
	 // Access a row of the Map 
	 // usage: rmap[i] returns row i of the RLEMap.
	 // row performs the same function  
	RLEPairs  * operator [](int i);
	RLEPairs * row(int i);

	 int pixelsInRegion(Point  ul, Point  lr);
	short int grayScale(Point  ul, Point  lr);


	void tilt_and_slant(double, int);
	int deskew(); 
	void tilt(double , int);
	void slant(double, int);
	void tilt_row(int, int, RLEPairs** , double, int);
	RLEPairs ** fMapData;    
	// Array length = fImageLength One list
	// for each row	


	  // prints RLEMap representation for row range
	void printPairs(int startRow, int endRow);  

private:
	// Size and status info
	int fImageLength;
	int fImageWidth;

	MapStatus fStatus;
};

void printMap(RLEMap * map);
void testpixelsBetween(RLEMap * map);
double get_skew(RLEMap*);

#endif