mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-24 11:09:06 +08:00
Fixed issue 248 and updated to the latest code
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@338 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
208f24ea04
commit
4eea92aef7
@ -53,7 +53,7 @@
|
||||
#define MAX_6BIT 128
|
||||
#define BLACK_PIX 0
|
||||
|
||||
static uinT8 grey_scales[FIXED_COLOURS] = {
|
||||
const uinT8 grey_scales[FIXED_COLOURS] = {
|
||||
0, 255, 76, 227, 151, 179, 28, 104,
|
||||
149, 72, 215, 67, 53, 44, 156, 137,
|
||||
110, 153, 79, 181, 166, 218, 55, 81,
|
||||
@ -63,6 +63,8 @@ static uinT8 grey_scales[FIXED_COLOURS] = {
|
||||
#undef EXTERN
|
||||
#define EXTERN
|
||||
|
||||
// Parameter remains truly global, as it is tough to make a member of Image
|
||||
// and the whole of this code is likely to go away in the future.
|
||||
EXTERN INT_VAR (image_default_resolution, 300, "Image resolution dpi");
|
||||
|
||||
/**********************************************************************
|
||||
@ -644,7 +646,7 @@ DLLSYM void fast_reduce_sub_image( //reduce rectangle
|
||||
//put in destination
|
||||
dest->put_line (xdest, ydest, destext, ©line, 0);
|
||||
}
|
||||
delete linesums;
|
||||
delete [] linesums;
|
||||
}
|
||||
|
||||
|
||||
@ -785,7 +787,7 @@ DLLSYM void reduce_sub_image( //reduce rectangle
|
||||
//put in destination
|
||||
dest->put_line (xdest, ydest, destext, ©line, 0);
|
||||
}
|
||||
delete linesums;
|
||||
delete [] linesums;
|
||||
}
|
||||
|
||||
|
||||
@ -1008,15 +1010,14 @@ void IMAGE::get_line( //get image line
|
||||
IMAGELINE *linebuf, //line to copy to
|
||||
inT32 margins //size of margins
|
||||
) {
|
||||
uinT8 *src; //source pointer
|
||||
uinT8 *dest; //destination pointer
|
||||
uinT8 *unpacksrc; //unpacking pointer
|
||||
inT8 bit; //bit index
|
||||
inT8 pixperbyte; //pixels per byte
|
||||
uinT8 white; //white colour
|
||||
inT32 pixel; //pixel index
|
||||
uinT8 *src; // source pointer
|
||||
uinT8 *dest; // destination pointer
|
||||
const uinT8 *unpacksrc; // unpacking pointer
|
||||
inT8 bit; // bit index
|
||||
inT8 pixperbyte; // pixels per byte
|
||||
uinT8 white; // white colour
|
||||
inT32 pixel; // pixel index
|
||||
|
||||
//test coords
|
||||
this->check_legal_access (x, y, width);
|
||||
if (width > xsize - x)
|
||||
width = xsize - x; //clip to image
|
||||
|
@ -94,7 +94,7 @@ typedef struct myrational
|
||||
#define SHORT_CODE_SIZE 64 //no of short codes
|
||||
#define LONG_CODE_SIZE 40 //no of long codes
|
||||
|
||||
static uinT16 short_white_codes[SHORT_CODE_SIZE] = {
|
||||
const uinT16 short_white_codes[SHORT_CODE_SIZE] = {
|
||||
0xac, 0x38, 0xe, 0x1, 0xd, 0x3, 0x7, 0xf,
|
||||
0x19, 0x5, 0x1c, 0x2, 0x4, 0x30, 0xb, 0x2b,
|
||||
0x15, 0x35, 0x72, 0x18, 0x8, 0x74, 0x60, 0x10,
|
||||
@ -104,7 +104,7 @@ static uinT16 short_white_codes[SHORT_CODE_SIZE] = {
|
||||
0xd0, 0x4a, 0xca, 0x2a, 0xaa, 0x24, 0xa4, 0x1a,
|
||||
0x9a, 0x5a, 0xda, 0x52, 0xd2, 0x4c, 0xcc, 0x2c
|
||||
};
|
||||
static uinT8 short_white_lengths[SHORT_CODE_SIZE] = {
|
||||
const uinT8 short_white_lengths[SHORT_CODE_SIZE] = {
|
||||
8, 6, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 6, 6, 6, 6,
|
||||
6, 6, 7, 7, 7, 7, 7, 7,
|
||||
@ -114,7 +114,7 @@ static uinT8 short_white_lengths[SHORT_CODE_SIZE] = {
|
||||
8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8
|
||||
};
|
||||
static uinT16 short_black_codes[SHORT_CODE_SIZE] = {
|
||||
const uinT16 short_black_codes[SHORT_CODE_SIZE] = {
|
||||
0x3b0, 0x2, 0x3, 0x1, 0x6, 0xc, 0x4, 0x18,
|
||||
0x28, 0x8, 0x10, 0x50, 0x70, 0x20, 0xe0, 0x30,
|
||||
0x3a0, 0x60, 0x40, 0x730, 0xb0, 0x1b0, 0x760, 0xa0,
|
||||
@ -129,7 +129,7 @@ static uinT16 short_black_codes[SHORT_CODE_SIZE] = {
|
||||
0x140, 0x1a0, 0x9a0, 0xd40,
|
||||
0x340, 0x5a0, 0x660, 0xe60
|
||||
};
|
||||
static uinT8 short_black_lengths[SHORT_CODE_SIZE] = {
|
||||
const uinT8 short_black_lengths[SHORT_CODE_SIZE] = {
|
||||
10, 3, 2, 2, 3, 4, 4, 5,
|
||||
6, 6, 7, 7, 7, 8, 8, 9,
|
||||
10, 10, 10, 11, 11, 11, 11, 11,
|
||||
@ -139,7 +139,7 @@ static uinT8 short_black_lengths[SHORT_CODE_SIZE] = {
|
||||
12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12
|
||||
};
|
||||
static uinT16 long_white_codes[LONG_CODE_SIZE] = {
|
||||
const uinT16 long_white_codes[LONG_CODE_SIZE] = {
|
||||
0x1b, 0x9, 0x3a, 0x76, 0x6c, 0xec, 0x26, 0xa6,
|
||||
0x16, 0xe6, 0x66, 0x166, 0x96, 0x196, 0x56, 0x156,
|
||||
0xd6, 0x1d6, 0x36, 0x136, 0xb6, 0x1b6, 0x32, 0x132,
|
||||
@ -147,14 +147,14 @@ static uinT16 long_white_codes[LONG_CODE_SIZE] = {
|
||||
0x80, 0x180, 0x580, 0x480, 0xc80,
|
||||
0x280, 0xa80, 0x680, 0xe80, 0x380, 0xb80, 0x780, 0xf80
|
||||
};
|
||||
static uinT8 long_white_lengths[LONG_CODE_SIZE] = {
|
||||
const uinT8 long_white_lengths[LONG_CODE_SIZE] = {
|
||||
5, 5, 6, 7, 8, 8, 8, 8,
|
||||
8, 8, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 6, 9, 11, 11, 11, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12
|
||||
};
|
||||
static uinT16 long_black_codes[LONG_CODE_SIZE] = {
|
||||
const uinT16 long_black_codes[LONG_CODE_SIZE] = {
|
||||
0x3c0, 0x130, 0x930, 0xda0,
|
||||
0xcc0, 0x2c0, 0xac0, 0x6c0,
|
||||
0x16c0, 0xa40, 0x1a40, 0x640,
|
||||
@ -165,7 +165,7 @@ static uinT16 long_black_codes[LONG_CODE_SIZE] = {
|
||||
0x80, 0x180, 0x580, 0x480, 0xc80,
|
||||
0x280, 0xa80, 0x680, 0xe80, 0x380, 0xb80, 0x780, 0xf80
|
||||
};
|
||||
static uinT8 long_black_lengths[LONG_CODE_SIZE] = {
|
||||
const uinT8 long_black_lengths[LONG_CODE_SIZE] = {
|
||||
10, 12, 12, 12, 12, 12, 12, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
@ -347,31 +347,29 @@ inT8 open_tif_image( //read header
|
||||
* Read a whole tif image into memory.
|
||||
**********************************************************************/
|
||||
|
||||
inT8 read_tif_image( //read whole image
|
||||
int fd, //file to read
|
||||
uinT8 *pixels, //pixels of image
|
||||
inT32 xsize, //size of image
|
||||
inT8 read_tif_image(int fd, // file to read
|
||||
uinT8 *pixels, // pixels of image
|
||||
inT32 xsize, // size of image
|
||||
inT32 ysize,
|
||||
inT8 bpp, //bits per pixel
|
||||
inT32 //bytes per line
|
||||
) {
|
||||
inT32 xindex; //indices in image
|
||||
inT8 bpp, // bits per pixel
|
||||
inT32) { // bytes per line
|
||||
inT32 xindex; // indices in image
|
||||
inT32 yindex;
|
||||
inT32 length; //short length
|
||||
inT32 biglength; //extender
|
||||
uinT8 *lengths; //current lengths
|
||||
uinT16 *codes; //current codes
|
||||
uinT16 codeword; //current code word
|
||||
IMAGELINE imageline; //current line
|
||||
IMAGE image; //dummy image
|
||||
R_BITSTREAM bits; //read bitstream
|
||||
uinT8 colour; //current colour
|
||||
inT32 length; // short length
|
||||
inT32 biglength; // extender
|
||||
const uinT8 *lengths; // current lengths
|
||||
const uinT16 *codes; // current codes
|
||||
uinT16 codeword; // current code word
|
||||
IMAGELINE imageline; // current line
|
||||
IMAGE image; // dummy image
|
||||
R_BITSTREAM bits; // read bitstream
|
||||
uinT8 colour; // current colour
|
||||
|
||||
image.capture (pixels, xsize, ysize, bpp);
|
||||
codeword = bits.open (fd); //open bitstream
|
||||
read_eol(&bits, codeword); //find end of line
|
||||
image.capture(pixels, xsize, ysize, bpp);
|
||||
codeword = bits.open(fd); // open bitstream
|
||||
read_eol(&bits, codeword); // find end of line
|
||||
for (yindex = ysize - 1; yindex >= 0; yindex--) {
|
||||
imageline.init ();
|
||||
imageline.init();
|
||||
colour = TRUE;
|
||||
for (xindex = 0; xindex < xsize;) {
|
||||
if (colour) {
|
||||
@ -539,7 +537,7 @@ inT8 write_tif_image( //write whole image
|
||||
MYRATIONAL resolution; //resolution
|
||||
TIFFENTRY entry; //current entry
|
||||
|
||||
static TIFFENTRY tags[ENTRIES] = {
|
||||
TIFFENTRY tags[ENTRIES] = {
|
||||
{0xfe, 4, 1, 0},
|
||||
{0x100, 3, 1, 0},
|
||||
{0x101, 3, 1, 0},
|
||||
@ -613,18 +611,6 @@ inT8 write_tif_image( //write whole image
|
||||
//line length
|
||||
size = COMPUTE_IMAGE_XDIM (xsize, bpp);
|
||||
size *= ysize; //total image size
|
||||
// if (photo==0)
|
||||
// {
|
||||
// tags[0].tag=0xfe;
|
||||
// tags[0].type=4;
|
||||
// tags[0].value=0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tags[0].tag=0xff;
|
||||
// tags[0].type=3;
|
||||
// tags[0].value=1;
|
||||
// }
|
||||
tags[1].value = xsize;
|
||||
tags[2].value = ysize;
|
||||
if (bpp == 24) {
|
||||
@ -693,31 +679,3 @@ inT8 write_tif_image( //write whole image
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* reverse32
|
||||
*
|
||||
* Byte swap the 32 bit number between Motorola & Intel format.
|
||||
**********************************************************************/
|
||||
|
||||
//inT32 reverse32( //reverse 32 bit int
|
||||
//uinT32 value //value to reverse
|
||||
//)
|
||||
//{
|
||||
// return (value>>24) | (value>>8) & 0xff00
|
||||
// | (value<<8) & 0xff0000 | (value<<24);
|
||||
//}
|
||||
|
||||
/**********************************************************************
|
||||
* reverse16
|
||||
*
|
||||
* Byte swap the 16 bit number between Motorola & Intel format.
|
||||
**********************************************************************/
|
||||
|
||||
//inT16 reverse16( //reverse 16 bit int
|
||||
//uinT16 value //value to reverse
|
||||
//)
|
||||
//{
|
||||
// return (value>>8) | (value<<8);
|
||||
//}
|
||||
|
@ -80,10 +80,4 @@ inT8 write_tif_image( //write whole image
|
||||
inT16 type, //format type
|
||||
inT16 photo //metric interp
|
||||
);
|
||||
//inT32 reverse32( //reverse 32 bit int
|
||||
//uinT32 value //value to reverse
|
||||
//);
|
||||
//inT16 reverse16( //reverse 16 bit int
|
||||
//uinT16 value //value to reverse
|
||||
//);
|
||||
#endif
|
||||
|
1926
image/imgunpk.h
1926
image/imgunpk.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user