#include <textlineprojection.h>
|
| TextlineProjection (int resolution) |
|
| ~TextlineProjection () |
|
void | ConstructProjection (TO_BLOCK *input_block, const FCOORD &rotation, Pix *nontext_map) |
|
void | PlotGradedBlobs (BLOBNBOX_LIST *blobs, ScrollView *win) |
|
void | MoveNonTextlineBlobs (BLOBNBOX_LIST *blobs, BLOBNBOX_LIST *small_blobs) const |
|
void | DisplayProjection () const |
|
int | DistanceOfBoxFromPartition (const TBOX &box, const ColPartition &part, const DENORM *denorm, bool debug) const |
|
int | DistanceOfBoxFromBox (const TBOX &from_box, const TBOX &to_box, bool horizontal_textline, const DENORM *denorm, bool debug) const |
|
int | VerticalDistance (bool debug, int x, int y1, int y2) const |
|
int | HorizontalDistance (bool debug, int x1, int x2, int y) const |
|
bool | BoxOutOfHTextline (const TBOX &box, const DENORM *denorm, bool debug) const |
|
int | EvaluateColPartition (const ColPartition &part, const DENORM *denorm, bool debug) const |
|
int | EvaluateBox (const TBOX &box, const DENORM *denorm, bool debug) const |
|
Definition at line 33 of file textlineprojection.h.
◆ TextlineProjection()
tesseract::TextlineProjection::TextlineProjection |
( |
int |
resolution | ) |
|
|
explicit |
Definition at line 47 of file textlineprojection.cpp.
48 : x_origin_(0), y_origin_(0), pix_(
nullptr) {
51 if (scale_factor_ < 1) scale_factor_ = 1;
◆ ~TextlineProjection()
tesseract::TextlineProjection::~TextlineProjection |
( |
| ) |
|
◆ BoxOutOfHTextline()
bool tesseract::TextlineProjection::BoxOutOfHTextline |
( |
const TBOX & |
box, |
|
|
const DENORM * |
denorm, |
|
|
bool |
debug |
|
) |
| const |
Definition at line 341 of file textlineprojection.cpp.
346 EvaluateBoxInternal(box, denorm, debug, &grad1, &grad2,
nullptr,
nullptr);
347 int worst_result = std::min(grad1, grad2);
348 int total_result = grad1 + grad2;
349 if (total_result >= 6)
return false;
352 if (worst_result < 0)
◆ ConstructProjection()
void tesseract::TextlineProjection::ConstructProjection |
( |
TO_BLOCK * |
input_block, |
|
|
const FCOORD & |
rotation, |
|
|
Pix * |
nontext_map |
|
) |
| |
Definition at line 64 of file textlineprojection.cpp.
68 TBOX image_box(0, 0, pixGetWidth(nontext_map), pixGetHeight(nontext_map));
70 y_origin_ = image_box.height();
71 int width = (image_box.width() + scale_factor_ - 1) / scale_factor_;
72 int height = (image_box.height() + scale_factor_ - 1) / scale_factor_;
74 pix_ = pixCreate(width, height, 8);
75 ProjectBlobs(&input_block->
blobs, rotation, image_box, nontext_map);
76 ProjectBlobs(&input_block->
large_blobs, rotation, image_box, nontext_map);
77 Pix* final_pix = pixBlockconv(pix_, 1, 1);
◆ DisplayProjection()
void tesseract::TextlineProjection::DisplayProjection |
( |
| ) |
const |
Definition at line 123 of file textlineprojection.cpp.
124 #ifndef GRAPHICS_DISABLED
125 int width = pixGetWidth(pix_);
126 int height = pixGetHeight(pix_);
127 Pix* pixc = pixCreate(width, height, 32);
128 int src_wpl = pixGetWpl(pix_);
129 int col_wpl = pixGetWpl(pixc);
130 uint32_t* src_data = pixGetData(pix_);
131 uint32_t* col_data = pixGetData(pixc);
132 for (
int y = 0; y < height; ++y, src_data += src_wpl, col_data += col_wpl) {
133 for (
int x = 0; x < width; ++x) {
134 int pixel = GET_DATA_BYTE(src_data, x);
137 composeRGBPixel(0, 0, pixel * 15, &result);
138 else if (pixel <= 145)
139 composeRGBPixel(0, (pixel - 17) * 2, 255, &result);
141 composeRGBPixel((pixel - 145) * 2, 255, 255, &result);
142 col_data[x] = result;
145 auto* win =
new ScrollView(
"Projection", 0, 0,
146 width, height, width, height);
147 win->Image(pixc, 0, 0);
150 #endif // GRAPHICS_DISABLED
◆ DistanceOfBoxFromBox()
int tesseract::TextlineProjection::DistanceOfBoxFromBox |
( |
const TBOX & |
from_box, |
|
|
const TBOX & |
to_box, |
|
|
bool |
horizontal_textline, |
|
|
const DENORM * |
denorm, |
|
|
bool |
debug |
|
) |
| const |
Definition at line 197 of file textlineprojection.cpp.
204 int parallel_gap = 0;
209 if (horizontal_textline) {
210 parallel_gap = from_box.
x_gap(to_box) + from_box.
width();
211 start_pt.
x = (from_box.
left() + from_box.
right()) / 2;
212 end_pt.
x = start_pt.
x;
214 start_pt.
y = from_box.
top();
215 end_pt.
y = std::min(to_box.
top(), start_pt.
y);
217 start_pt.
y = from_box.
bottom();
218 end_pt.
y = std::max(to_box.
bottom(), start_pt.
y);
221 parallel_gap = from_box.
y_gap(to_box) + from_box.
height();
223 start_pt.
x = from_box.
right();
224 end_pt.
x = std::min(to_box.
right(), start_pt.
x);
226 start_pt.
x = from_box.
left();
227 end_pt.
x = std::max(to_box.
left(), start_pt.
x);
229 start_pt.
y = (from_box.
bottom() + from_box.
top()) / 2;
230 end_pt.
y = start_pt.
y;
236 int perpendicular_gap = 0;
240 if (start_pt.
x != end_pt.
x || start_pt.
y != end_pt.
y) {
241 if (denorm !=
nullptr) {
246 if (abs(start_pt.
y - end_pt.
y) >= abs(start_pt.
x - end_pt.
x)) {
◆ DistanceOfBoxFromPartition()
int tesseract::TextlineProjection::DistanceOfBoxFromPartition |
( |
const TBOX & |
box, |
|
|
const ColPartition & |
part, |
|
|
const DENORM * |
denorm, |
|
|
bool |
debug |
|
) |
| const |
◆ EvaluateBox()
int tesseract::TextlineProjection::EvaluateBox |
( |
const TBOX & |
box, |
|
|
const DENORM * |
denorm, |
|
|
bool |
debug |
|
) |
| const |
Definition at line 413 of file textlineprojection.cpp.
415 return EvaluateBoxInternal(box, denorm, debug,
nullptr,
nullptr,
nullptr,
nullptr);
◆ EvaluateColPartition()
int tesseract::TextlineProjection::EvaluateColPartition |
( |
const ColPartition & |
part, |
|
|
const DENORM * |
denorm, |
|
|
bool |
debug |
|
) |
| const |
Definition at line 362 of file textlineprojection.cpp.
365 if (part.IsSingleton())
366 return EvaluateBox(part.bounding_box(), denorm, debug);
368 TBOX box = part.bounding_box();
375 box = part.bounding_box();
377 box.
set_top(part.median_top());
381 tprintf(
"Partition hresult=%d, vresult=%d from:", hresult, vresult);
382 part.bounding_box().print();
385 return hresult >= -vresult ? hresult : vresult;
◆ HorizontalDistance()
int tesseract::TextlineProjection::HorizontalDistance |
( |
bool |
debug, |
|
|
int |
x1, |
|
|
int |
x2, |
|
|
int |
y |
|
) |
| const |
Definition at line 309 of file textlineprojection.cpp.
311 x1 = ImageXToProjectionX(x1);
312 x2 = ImageXToProjectionX(x2);
313 y = ImageYToProjectionY(y);
314 if (x1 == x2)
return 0;
315 int wpl = pixGetWpl(pix_);
316 int step = x1 < x2 ? 1 : -1;
317 uint32_t* data = pixGetData(pix_) + y * wpl;
318 int prev_pixel = GET_DATA_BYTE(data, x1);
320 int right_way_steps = 0;
321 for (
int x = x1; x != x2; x += step) {
322 int pixel = GET_DATA_BYTE(data, x + step);
324 tprintf(
"At (%d,%d), pix = %d, prev=%d\n",
325 x + step, y, pixel, prev_pixel);
326 if (pixel < prev_pixel)
328 else if (pixel > prev_pixel)
◆ MoveNonTextlineBlobs()
void tesseract::TextlineProjection::MoveNonTextlineBlobs |
( |
BLOBNBOX_LIST * |
blobs, |
|
|
BLOBNBOX_LIST * |
small_blobs |
|
) |
| const |
Definition at line 106 of file textlineprojection.cpp.
108 BLOBNBOX_IT it(blobs);
109 BLOBNBOX_IT small_it(small_blobs);
110 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
117 small_it.add_to_end(it.extract());
◆ PlotGradedBlobs()
void tesseract::TextlineProjection::PlotGradedBlobs |
( |
BLOBNBOX_LIST * |
blobs, |
|
|
ScrollView * |
win |
|
) |
| |
Definition at line 84 of file textlineprojection.cpp.
86 #ifndef GRAPHICS_DISABLED
87 BLOBNBOX_IT it(blobs);
88 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
99 #endif // GRAPHICS_DISABLED
◆ VerticalDistance()
int tesseract::TextlineProjection::VerticalDistance |
( |
bool |
debug, |
|
|
int |
x, |
|
|
int |
y1, |
|
|
int |
y2 |
|
) |
| const |
Definition at line 276 of file textlineprojection.cpp.
278 x = ImageXToProjectionX(x);
279 y1 = ImageYToProjectionY(y1);
280 y2 = ImageYToProjectionY(y2);
281 if (y1 == y2)
return 0;
282 int wpl = pixGetWpl(pix_);
283 int step = y1 < y2 ? 1 : -1;
284 uint32_t* data = pixGetData(pix_) + y1 * wpl;
286 int prev_pixel = GET_DATA_BYTE(data, x);
288 int right_way_steps = 0;
289 for (
int y = y1; y != y2; y += step) {
291 int pixel = GET_DATA_BYTE(data, x);
293 tprintf(
"At (%d,%d), pix = %d, prev=%d\n",
294 x, y + step, pixel, prev_pixel);
295 if (pixel < prev_pixel)
297 else if (pixel > prev_pixel)
The documentation for this class was generated from the following files: