Paragraph Setting, Creating and Retrieving Normalized Images
Create and retrieve a normalized image using an instance of the paragraph recognition class. The normalized image is an image that is corrected so that the tilt of the paragraph is zero, based on vertical or horizontal writing. When msetprocess(PREPROCESS_EXACT) is specified, the normalized image is the same as the rotated image of the bitmap within the paragraph. When msetprocess(PREPROCESS_INSIDE) is specified, the normalized image consists only of the primitives within the paragraph that do not intersect with the frame of the paragraph.
// Set the paragraph properties
void msetblock(OCRBlock* pblock, double angle, int background, int linedirection);
Input:
OCRBlock* pblock; // The bounding rectangle of the paragraph
    // Baseline
    typedef struct {
        double x1;
        double y1;
        double x2;
        double y2;
    } OCRBaseline;
    // Slanted rectangle
    typedef struct {
        OCRBaseline baseline; // Baseline
        double thickness; // Height (width) of the rectangle
    } OCRBlock;
double angle; // Angle of the baseline
// For horizontal writing, the angle from the horizontal baseline
// (in radians: positive in clockwise direction)
// For vertical writing, the angle from the vertical baseline
// (in radians: positive in clockwise direction)
int background; // 0 or 1 for the background
int linedirection; // 0 for horizontal writing / 1 for vertical writing

// Create a normalized image
// Create an image with the baseline angle set to 0
int mregularize(); // Process the internal image with 4-connectivity
int mregularize8(); // Process the internal image with 8-connectivity
Return value:
MEMORY_SHORTAGE... Failed to allocate memory for the normalized image.
// Access the normalized image
// Retrieve the normalized image
// Do not release the normalized image buffer outside the library, as it is allocated internally
void mgetregularizedata(unsigned char*& data, int& width, int& height);
Output:
unsigned char*& data; // Address of the normalized image
int& width; // Width of the normalized image in pixels
int& height; // Height of the normalized image in pixels

Example
#include	"ocrdef.h"
#include	"ocrco.h"
#include	"cjocrstock.h"
#include	"cjocrdict98.h"
#include	"cjocrpat98.h"
#include	"cjocrrec98.h"
#include	"cjocrline98.h"
#include	"cjocrlang.h"
#include	"cjocrblock.h"
#include	"errcode.h"
...
....
// Create pattern class
CJocrPattern*	pattern = new CJocrPattern;
int ret = pattern->mallocmemory();
if(ret < 0) {
	printf("Pattern class memory allocation error");
	delete pattern;
	exit(1);
}
// Create dictionary class
CJocrDict* pjocrdict = new CJocrDict;
pjocrdict->msetsystemdict("c:\\dic\\feature\\system");
pjocrdict->msetsystemdict("c:\\dic\\feature\\systemfat");
pjocrdict->msetuserdict("c:\\dic\\feature\\user");
ret = pjocrdict->mloaddict();
if(ret < 0) {
	printf("Error");
	delete pjocrdict;
	delete pattern;
	exit(1);
}
// Create single character recognition class
CJocrRecognize* precognize = new CJocrRecognize;
precognize->msetpatter(pattern);
precognize->msetdict(pjocrdict);
// Initialize single character recognition class
ret = precognize->mallocmemory();
if(ret < 0) {
	printf("Error");
	delete precognize;
	delete pjocrdict;
	delete pattern;
	exit(1);
}
// Create line recognition class with language processing
CJocrLang* pjocrlang = new CJocrLang;
pjocrlang->msetpatter(pattern);
pjocrlang->msetrecognize(precognize);
// Create paragraph recognition class
CJocrBlock* pjocrblock = new CJocrBlock;
pjocrblock->msetlang(pjocrlang);
pjocrblock->msetprocess(PREPROCESS_INSIDE);	// Exclude primitives that touch the frame
// Set document
pjocrblock->msetdocument(mdata,mwidth,mheight);
pjocrblock->msetdpi(400);		// Resolution: 400dpi
// Set paragraph
// Set block
OCRBlock	ocrblock;
ocrblock.baseline.x1 = 100;
ocrblock.baseline.y1 = 100;
ocrblock.baseline.x2 = 300;
ocrblock.baseline.y2 = 200;
ocrblock.thickness = 100;
// Baseline: (100,100)-(300,200)
// Line height: 100
// No background
// Set a horizontally written block
pjocrblock->msetblock(ocrblock,atan2(ocrblock.baseline.y2 - ocrblock.baseline.y1,ocrblock.baseline.x2 - ocrblock.baseline.x1),0,0);
// Create normalized image
ret = pjocrblock->mregularize();
if(ret < 0) {
	printf("Error");
	delete pjocrblock;
	delete pjocrlang;
	delete precognize;
	delete pjocrdict;
	delete pattern;
	exit(1);
}
// Access normalized image
unsigned char*	prdata;
int				rwidth;
int				rheight;
mpblock->mgetregularizedata(pdata,rwidth,rheight);
....
...
..
delete pjocrblock;
delete pjocrlang;
delete precognize;
delete pjocrdict;
delete pattern;