Removed dependence on IMAGE class

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@948 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
theraysmith@gmail.com 2014-01-09 17:36:42 +00:00
parent 28c00478c6
commit 9689f3f828
7 changed files with 32 additions and 74 deletions

View File

@ -1,7 +1,7 @@
AM_CPPFLAGS += \
-DUSE_STD_NAMESPACE \
-I$(top_srcdir)/ccstruct -I$(top_srcdir)/ccutil \
-I$(top_srcdir)/image -I$(top_srcdir)/viewer \
-I$(top_srcdir)/viewer \
-I$(top_srcdir)/ccmain -I$(top_srcdir)/wordrec -I$(top_srcdir)/api \
-I$(top_srcdir)/cutil -I$(top_srcdir)/classify -I$(top_srcdir)/dict \
-I$(top_srcdir)/opencl
@ -36,7 +36,6 @@ libtesseract_textord_la_LDFLAGS = -version-info $(GENERIC_LIBRARY_VERSION)
libtesseract_textord_la_LIBADD = \
../ccstruct/libtesseract_ccstruct.la \
../ccutil/libtesseract_ccutil.la \
../image/libtesseract_image.la \
../viewer/libtesseract_viewer.la \
../wordrec/libtesseract_wordrec.la \
../cutil/libtesseract_cutil.la \

View File

@ -21,7 +21,6 @@
#include "devanagari_processing.h"
#include "allheaders.h"
#include "tordmain.h"
#include "img.h"
#include "statistc.h"
// Flags controlling the debugging information for shiro-rekha splitting

View File

@ -336,11 +336,7 @@ void extract_edges(Pix* pix, // thresholded image
C_OUTLINE_LIST outlines; // outlines in block
C_OUTLINE_IT out_it = &outlines;
// TODO(rays) move the pix all the way down to the bottom.
IMAGE image;
image.FromPix(pix);
block_edges(&image, block, &out_it);
block_edges(pix, block, &out_it);
ICOORD bleft; // block box
ICOORD tright;
block->bounding_box(bleft, tright);

View File

@ -22,7 +22,6 @@
#include "scrollview.h"
#include "params.h"
#include "img.h"
#include "ocrblock.h"
#include "coutln.h"
#include "crakedge.h"

View File

@ -22,7 +22,6 @@
#include "scrollview.h"
#include "params.h"
#include "img.h"
#include "pdblock.h"
#include "coutln.h"
#include "crakedge.h"

View File

@ -17,8 +17,10 @@
*
**********************************************************************/
#include "edgloop.h"
#include "scanedg.h"
#include "scanedg.h"
#include "allheaders.h"
#include "edgloop.h"
#define WHITE_PIX 1 /*thresholded colours */
#define BLACK_PIX 0
@ -31,49 +33,47 @@
* Extract edges from a PDBLK.
**********************************************************************/
void block_edges(IMAGE *t_image, // thresholded image
void block_edges(Pix *t_pix, // thresholded image
PDBLK *block, // block in image
C_OUTLINE_IT* outline_it) {
uinT8 margin; // margin colour
inT16 x; // line coords
inT16 y; // current line
ICOORD bleft; // bounding box
ICOORD tright;
ICOORD block_bleft; // bounding box
ICOORD block_tright;
int xindex; // index to pixel
BLOCK_LINE_IT line_it = block; // line iterator
IMAGELINE bwline; // thresholded line
int width = pixGetWidth(t_pix);
int height = pixGetHeight(t_pix);
int wpl = pixGetWpl(t_pix);
// lines in progress
CRACKEDGE **ptrline = new CRACKEDGE*[t_image->get_xsize()+1];
CRACKEDGE **ptrline = new CRACKEDGE*[width + 1];
CRACKEDGE *free_cracks = NULL;
block->bounding_box(bleft, tright); // block box
block_bleft = bleft;
block_tright = tright;
for (x = tright.x() - bleft.x(); x >= 0; x--)
ptrline[x] = NULL; //no lines in progress
int block_width = tright.x() - bleft.x();
for (int x = block_width; x >= 0; x--)
ptrline[x] = NULL; // no lines in progress
bwline.init(t_image->get_xsize());
uinT8* bwline = new uinT8[width];
margin = WHITE_PIX;
uinT8 margin = WHITE_PIX;
for (y = tright.y() - 1; y >= bleft.y() - 1; y--) {
if (y >= block_bleft.y() && y < block_tright.y()) {
t_image->get_line(bleft.x(), y, tright.x() - bleft.x(), &bwline, 0);
make_margins(block, &line_it, bwline.pixels, margin, bleft.x(),
tright.x(), y);
for (int y = tright.y() - 1; y >= bleft.y() - 1; y--) {
if (y >= bleft.y() && y < tright.y()) {
// Get the binary pixels from the image.
l_uint32* line = pixGetData(t_pix) + wpl * (height - 1 - y);
for (int x = 0; x < block_width; ++x) {
bwline[x] = GET_DATA_BIT(line, x + bleft.x()) ^ 1;
}
make_margins(block, &line_it, bwline, margin, bleft.x(), tright.x(), y);
} else {
x = tright.x() - bleft.x();
for (xindex = 0; xindex < x; xindex++)
bwline.pixels[xindex] = margin;
memset(bwline, margin, block_width * sizeof(bwline[0]));
}
line_edges(bleft.x(), y, tright.x() - bleft.x(),
margin, bwline.pixels, ptrline, &free_cracks, outline_it);
line_edges(bleft.x(), y, block_width,
margin, bwline, ptrline, &free_cracks, outline_it);
}
free_crackedges(free_cracks); // really free them
delete[] ptrline;
delete[] bwline;
}
@ -134,39 +134,6 @@ void make_margins( //get a line
}
}
/**********************************************************************
* whiteout_block
*
* Extract edges from a PDBLK.
**********************************************************************/
void whiteout_block( //clean it
IMAGE *t_image, //threshold image
PDBLK *block //block in image
) {
inT16 x; //line coords
inT16 y; //current line
inT16 xext; //line width
int xindex; //index to pixel
uinT8 *dest; //destination pixel
TBOX block_box; //bounding box
BLOCK_LINE_IT line_it = block; //line iterator
IMAGELINE bwline; //thresholded line
block_box = block->bounding_box ();
for (y = block_box.bottom (); y < block_box.top (); y++) {
//find line limits
x = line_it.get_line (y, xext);
t_image->get_line (x, y, xext, &bwline, 0);
dest = bwline.pixels; //destination pixel
for (xindex = 0; xindex < xext; xindex++)
*dest++ = 1;
t_image->put_line (x, y, xext, &bwline, 0);
}
}
/**********************************************************************
* line_edges
*

View File

@ -22,7 +22,6 @@
#include "params.h"
#include "scrollview.h"
#include "img.h"
#include "pdblock.h"
#include "crakedge.h"
@ -34,7 +33,9 @@ struct CrackPos {
int y;
};
void block_edges(IMAGE *t_image, // thresholded image
struct Pix;
void block_edges(Pix *t_image, // thresholded image
PDBLK *block, // block in image
C_OUTLINE_IT* outline_it);
void make_margins(PDBLK *block, // block in image
@ -44,8 +45,6 @@ void make_margins(PDBLK *block, // block in image
inT16 left, // block edges
inT16 right,
inT16 y); // line coord );
void whiteout_block(IMAGE *t_image, // thresholded image
PDBLK *block); // block in image
void line_edges(inT16 x, // coord of line start
inT16 y, // coord of line
inT16 xext, // width of line