#include <bbgrid.h>
|
| IntGrid () |
|
| IntGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright) |
|
| ~IntGrid () override |
|
void | Init (int gridsize, const ICOORD &bleft, const ICOORD &tright) |
|
void | Clear () |
|
void | Rotate (const FCOORD &rotation) |
|
IntGrid * | NeighbourhoodSum () const |
|
int | GridCellValue (int grid_x, int grid_y) const |
|
void | SetGridCell (int grid_x, int grid_y, int value) |
|
bool | RectMostlyOverThreshold (const TBOX &rect, int threshold) const |
|
bool | AnyZeroInRect (const TBOX &rect) const |
|
Image | ThresholdToPix (int threshold) const |
|
| GridBase ()=default |
|
| GridBase (int gridsize, const ICOORD &bleft, const ICOORD &tright) |
|
virtual | ~GridBase () |
|
void | Init (int gridsize, const ICOORD &bleft, const ICOORD &tright) |
|
int | gridsize () const |
|
int | gridwidth () const |
|
int | gridheight () const |
|
const ICOORD & | bleft () const |
|
const ICOORD & | tright () const |
|
void | GridCoords (int x, int y, int *grid_x, int *grid_y) const |
|
void | ClipGridCoords (int *x, int *y) const |
|
Definition at line 97 of file bbgrid.h.
◆ IntGrid() [1/2]
tesseract::IntGrid::IntGrid |
( |
| ) |
|
Definition at line 65 of file bbgrid.cpp.
65 {
66 grid_ = nullptr;
67}
◆ IntGrid() [2/2]
tesseract::IntGrid::IntGrid |
( |
int |
gridsize, |
|
|
const ICOORD & |
bleft, |
|
|
const ICOORD & |
tright |
|
) |
| |
Definition at line 69 of file bbgrid.cpp.
69 : grid_(nullptr) {
71}
const ICOORD & bleft() const
const ICOORD & tright() const
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
◆ ~IntGrid()
tesseract::IntGrid::~IntGrid |
( |
| ) |
|
|
override |
Definition at line 73 of file bbgrid.cpp.
73 {
74 delete[] grid_;
75}
◆ AnyZeroInRect()
bool tesseract::IntGrid::AnyZeroInRect |
( |
const TBOX & |
rect | ) |
const |
Definition at line 173 of file bbgrid.cpp.
173 {
174 int min_x, min_y, max_x, max_y;
175 GridCoords(rect.left(), rect.bottom(), &min_x, &min_y);
176 GridCoords(rect.right(), rect.top(), &max_x, &max_y);
177 for (
int y = min_y;
y <= max_y; ++
y) {
178 for (
int x = min_x;
x <= max_x; ++
x) {
180 return true;
181 }
182 }
183 }
184 return false;
185}
void GridCoords(int x, int y, int *grid_x, int *grid_y) const
int GridCellValue(int grid_x, int grid_y) const
◆ Clear()
void tesseract::IntGrid::Clear |
( |
| ) |
|
◆ GridCellValue()
int tesseract::IntGrid::GridCellValue |
( |
int |
grid_x, |
|
|
int |
grid_y |
|
) |
| const |
|
inline |
Definition at line 120 of file bbgrid.h.
120 {
123 }
void ClipGridCoords(int *x, int *y) const
◆ Init()
void tesseract::IntGrid::Init |
( |
int |
gridsize, |
|
|
const ICOORD & |
bleft, |
|
|
const ICOORD & |
tright |
|
) |
| |
Definition at line 79 of file bbgrid.cpp.
79 {
81 delete[] grid_;
84}
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
◆ NeighbourhoodSum()
IntGrid * tesseract::IntGrid::NeighbourhoodSum |
( |
| ) |
const |
Definition at line 131 of file bbgrid.cpp.
131 {
135 int cell_count = 0;
136 for (int yoffset = -1; yoffset <= 1; ++yoffset) {
137 for (int xoffset = -1; xoffset <= 1; ++xoffset) {
138 int grid_x =
x + xoffset;
139 int grid_y =
y + yoffset;
142 }
143 }
145 sumgrid->SetGridCell(
x,
y, cell_count);
146 }
147 }
148 }
149 return sumgrid;
150}
◆ RectMostlyOverThreshold()
bool tesseract::IntGrid::RectMostlyOverThreshold |
( |
const TBOX & |
rect, |
|
|
int |
threshold |
|
) |
| const |
Definition at line 154 of file bbgrid.cpp.
154 {
155 int min_x, min_y, max_x, max_y;
156 GridCoords(rect.left(), rect.bottom(), &min_x, &min_y);
157 GridCoords(rect.right(), rect.top(), &max_x, &max_y);
158 int total_area = 0;
159 for (
int y = min_y;
y <= max_y; ++
y) {
160 for (
int x = min_x;
x <= max_x; ++
x) {
162 if (
value > threshold) {
164 cell_box &= rect;
165 total_area += cell_box.area();
166 }
167 }
168 }
169 return total_area * 2 > rect.area();
170}
◆ Rotate()
void tesseract::IntGrid::Rotate |
( |
const FCOORD & |
rotation | ) |
|
Definition at line 99 of file bbgrid.cpp.
99 {
100 ASSERT_HOST(rotation.x() == 0.0f || rotation.y() == 0.0f);
101 ICOORD old_bleft(
bleft());
102
106 box.rotate(rotation);
107 int *old_grid = grid_;
108 grid_ = nullptr;
110
111 int oldi = 0;
112 FCOORD x_step(rotation);
114 for (int oldy = 0; oldy < old_height; ++oldy) {
115 FCOORD line_pos(old_bleft.x(), old_bleft.y() +
gridsize() * oldy);
116 line_pos.rotate(rotation);
117 for (int oldx = 0; oldx < old_width; ++oldx, line_pos += x_step, ++oldi) {
118 int grid_x, grid_y;
119 GridCoords(
static_cast<int>(line_pos.x() + 0.5),
static_cast<int>(line_pos.y() + 0.5),
120 &grid_x, &grid_y);
121 grid_[grid_y *
gridwidth() + grid_x] = old_grid[oldi];
122 }
123 }
124 delete[] old_grid;
125}
◆ SetGridCell()
void tesseract::IntGrid::SetGridCell |
( |
int |
grid_x, |
|
|
int |
grid_y, |
|
|
int |
value |
|
) |
| |
|
inline |
◆ ThresholdToPix()
Image tesseract::IntGrid::ThresholdToPix |
( |
int |
threshold | ) |
const |
Definition at line 190 of file bbgrid.cpp.
190 {
198 pixRasterop(pix,
x * cellsize,
tright().
y() - ((
y + 1) * cellsize), cellsize, cellsize,
199 PIX_SET, nullptr, 0, 0);
200 }
201 }
202 }
203 return pix;
204}
The documentation for this class was generated from the following files:
- /media/home/debian/src/github/tesseract-ocr/tesseract/src/textord/bbgrid.h
- /media/home/debian/src/github/tesseract-ocr/tesseract/src/textord/bbgrid.cpp