tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
C_OUTLINE Class Reference

#include <coutln.h>

Inheritance diagram for C_OUTLINE:
Collaboration diagram for C_OUTLINE:

Public Member Functions

 C_OUTLINE ()
 
 ~C_OUTLINE ()
 
bool flag (C_OUTLINE_FLAGS mask) const
 
void set_flag (C_OUTLINE_FLAGS mask, bool value)
 
C_OUTLINE_LIST * child ()
 
const TBOXbounding_box () const
 
void set_step (int16_t stepindex, int8_t stepdir)
 
void set_step (int16_t stepindex, DIR128 stepdir)
 
int32_t pathlength () const
 
DIR128 step_dir (int index) const
 
ICOORD step (int index) const
 
const ICOORDstart_pos () const
 
ICOORD position_at_index (int index) const
 
FCOORD sub_pixel_pos_at_index (const ICOORD &pos, int index) const
 
int direction_at_index (int index) const
 
int edge_strength_at_index (int index) const
 
int chain_code (int index) const
 
bool operator> (C_OUTLINE &other) const
 
C_OUTLINE::area

Compute the area of the outline.

int32_t area () const
 
C_OUTLINE::perimeter

Compute the perimeter of the outline and its first level children.

int32_t perimeter () const
 
C_OUTLINE::outer_area

Compute the area of the outline.

int32_t outer_area () const
 
C_OUTLINE::count_transitions

Compute the number of x and y maxes and mins in the outline.

Parameters
thresholdwinding number on size
int32_t count_transitions (int32_t threshold)
 
C_OUTLINE::operator<
Returns
TRUE if the left operand is inside the right one.
Parameters
otherother outline
bool operator< (const C_OUTLINE &other) const
 
C_OUTLINE::winding_number
Returns
the winding number of the outline around the given point.
Parameters
pointpoint to wind around
int16_t winding_number (ICOORD testpt) const
 
int16_t turn_direction () const
 
C_OUTLINE::reverse

Reverse the direction of an outline.

void reverse ()
 
C_OUTLINE::move

Move C_OUTLINE by vector

Parameters
vecvector to reposition OUTLINE by
void move (const ICOORD vec)
 
bool IsLegallyNested () const
 
void RemoveSmallRecursive (int min_size, C_OUTLINE_IT *it)
 
void ComputeEdgeOffsets (int threshold, Pix *pix)
 
void ComputeBinaryOffsets ()
 
void render (int left, int top, Pix *pix) const
 
void render_outline (int left, int top, Pix *pix) const
 
C_OUTLINE::plot

Draw the outline in the given colour.

Parameters
windowwindow to draw in
colourcolour to draw in
void plot (ScrollView *window, ScrollView::Color colour) const
 
void plot_normed (const DENORM &denorm, ScrollView::Color colour, ScrollView *window) const
 

Static Public Member Functions

static C_OUTLINEdeep_copy (const C_OUTLINE *src)
 

Static Public Attributes

static const int kMaxOutlineLength = 16000
 

Private Member Functions

int step_mem () const
 

Private Attributes

TBOX box
 
ICOORD start
 
int16_t stepcount
 
BITS16 flags
 
uint8_t * steps
 
EdgeOffsetoffsets
 
C_OUTLINE_LIST children
 

Static Private Attributes

static ICOORD step_coords [4]
 

C_OUTLINE::C_OUTLINE

Constructor to build a C_OUTLINE from a rotation of a C_OUTLINE.

Parameters
srclineoutline to rotate
rotationrotate to coord
 C_OUTLINE (CRACKEDGE *startpt, ICOORD bot_left, ICOORD top_right, int16_t length)
 
 C_OUTLINE (ICOORD startpt, DIR128 *new_steps, int16_t length)
 
 C_OUTLINE (C_OUTLINE *srcline, FCOORD rotation)
 
static void FakeOutline (const TBOX &box, C_OUTLINE_LIST *outlines)
 

C_OUTLINE::operator=

Assignment - deep copy data

Parameters
sourceassign from this
C_OUTLINEoperator= (const C_OUTLINE &source)
 
static ICOORD chain_step (int chaindir)
 
void increment_step (int s, int increment, ICOORD *pos, int *dir_counts, int *pos_totals) const
 

Constructor & Destructor Documentation

◆ C_OUTLINE() [1/4]

C_OUTLINE::C_OUTLINE ( )
inline

◆ C_OUTLINE() [2/4]

C_OUTLINE::C_OUTLINE ( CRACKEDGE startpt,
ICOORD  bot_left,
ICOORD  top_right,
int16_t  length 
)

◆ C_OUTLINE() [3/4]

C_OUTLINE::C_OUTLINE ( ICOORD  startpt,
DIR128 new_steps,
int16_t  length 
)

◆ C_OUTLINE() [4/4]

C_OUTLINE::C_OUTLINE ( C_OUTLINE srcline,
FCOORD  rotation 
)

◆ ~C_OUTLINE()

C_OUTLINE::~C_OUTLINE ( )
inline

Member Function Documentation

◆ area()

int32_t C_OUTLINE::area ( ) const

◆ bounding_box()

const TBOX& C_OUTLINE::bounding_box ( ) const
inline

◆ chain_code()

int C_OUTLINE::chain_code ( int  index) const
inline

◆ chain_step()

ICOORD C_OUTLINE::chain_step ( int  chaindir)
static

◆ child()

C_OUTLINE_LIST* C_OUTLINE::child ( )
inline

◆ ComputeBinaryOffsets()

void C_OUTLINE::ComputeBinaryOffsets ( )

Adds sub-pixel resolution EdgeOffsets for the outline using only a binary image source.

Runs a sliding window of 5 edge steps over the outline, maintaining a count of the number of steps in each of the 4 directions in the window, and a sum of the x or y position of each step (as appropriate to its direction.) Ignores single-count steps EXCEPT the sharp U-turn and smoothes out the perpendicular direction. Eg

* ___              ___       Chain code from the left:
*    |___    ___   ___|      222122212223221232223000
*        |___|  |_|          Corresponding counts of each direction:
*                          0   00000000000000000123
*                          1   11121111001111100000
*                          2   44434443443333343321
*                          3   00000001111111112111
* Count of direction at center 41434143413313143313
* Step gets used?              YNYYYNYYYNYYNYNYYYyY (y= U-turn exception)
* Path redrawn showing only the used points:
* ___              ___
*     ___    ___   ___|
*         ___    _
* 

Sub-pixel edge position cannot be shown well with ASCII-art, but each horizontal step's y position is the mean of the y positions of the steps in the same direction in the sliding window, which makes a much smoother outline, without losing important detail.

◆ ComputeEdgeOffsets()

void C_OUTLINE::ComputeEdgeOffsets ( int  threshold,
Pix *  pix 
)

Adds sub-pixel resolution EdgeOffsets for the outline if the supplied pix is 8-bit. Does nothing otherwise. Operation: Consider the following near-horizontal line:

*   _________
*            |________
*                     |________
* 

At every position along this line, the gradient direction will be close to vertical. Extrapoaltion/interpolation of the position of the threshold that was used to binarize the image gives a more precise vertical position for each horizontal step, and the conflict in step direction and gradient direction can be used to ignore the vertical steps.

◆ count_transitions()

int32_t C_OUTLINE::count_transitions ( int32_t  threshold)

◆ deep_copy()

static C_OUTLINE* C_OUTLINE::deep_copy ( const C_OUTLINE src)
inlinestatic

◆ direction_at_index()

int C_OUTLINE::direction_at_index ( int  index) const
inline

◆ edge_strength_at_index()

int C_OUTLINE::edge_strength_at_index ( int  index) const
inline

◆ FakeOutline()

void C_OUTLINE::FakeOutline ( const TBOX box,
C_OUTLINE_LIST *  outlines 
)
static

◆ flag()

bool C_OUTLINE::flag ( C_OUTLINE_FLAGS  mask) const
inline

◆ increment_step()

void C_OUTLINE::increment_step ( int  s,
int  increment,
ICOORD pos,
int *  dir_counts,
int *  pos_totals 
) const
private

Helper for ComputeBinaryOffsets. Increments pos, dir_counts, pos_totals by the step, increment, and vertical step ? x : y position * increment at step s Mod stepcount respectively. Used to add or subtract the direction and position to/from accumulators of a small neighbourhood.

◆ IsLegallyNested()

bool C_OUTLINE::IsLegallyNested ( ) const

Returns true if *this and its children are legally nested. The outer area of a child should have the opposite sign to the parent. If not, it means we have discarded an outline in between (probably due to excessive length).

◆ move()

void C_OUTLINE::move ( const ICOORD  vec)

◆ operator<()

bool C_OUTLINE::operator< ( const C_OUTLINE other) const

◆ operator=()

C_OUTLINE & C_OUTLINE::operator= ( const C_OUTLINE source)

◆ operator>()

bool C_OUTLINE::operator> ( C_OUTLINE other) const
inline

◆ outer_area()

int32_t C_OUTLINE::outer_area ( ) const

◆ pathlength()

int32_t C_OUTLINE::pathlength ( ) const
inline

◆ perimeter()

int32_t C_OUTLINE::perimeter ( ) const

◆ plot()

void C_OUTLINE::plot ( ScrollView window,
ScrollView::Color  colour 
) const

◆ plot_normed()

void C_OUTLINE::plot_normed ( const DENORM denorm,
ScrollView::Color  colour,
ScrollView window 
) const

Draws the outline in the given colour, normalized using the given denorm, making use of sub-pixel accurate information if available.

◆ position_at_index()

ICOORD C_OUTLINE::position_at_index ( int  index) const
inline

◆ RemoveSmallRecursive()

void C_OUTLINE::RemoveSmallRecursive ( int  min_size,
C_OUTLINE_IT *  it 
)

If this outline is smaller than the given min_size, delete this and remove from its list, via *it, after checking that *it points to this. Otherwise, if any children of this are too small, delete them. On entry, *it must be an iterator pointing to this. If this gets deleted then this is extracted from *it, so an iteration can continue.

Parameters
min_sizeminimum size for outline
itoutline iterator

◆ render()

void C_OUTLINE::render ( int  left,
int  top,
Pix *  pix 
) const

Renders the outline to the given pix, with left and top being the coords of the upper-left corner of the pix.

◆ render_outline()

void C_OUTLINE::render_outline ( int  left,
int  top,
Pix *  pix 
) const

Renders just the outline to the given pix (no fill), with left and top being the coords of the upper-left corner of the pix.

Parameters
leftcoord
topcoord
pixthe pix to outline

◆ reverse()

void C_OUTLINE::reverse ( )

◆ set_flag()

void C_OUTLINE::set_flag ( C_OUTLINE_FLAGS  mask,
bool  value 
)
inline

◆ set_step() [1/2]

void C_OUTLINE::set_step ( int16_t  stepindex,
int8_t  stepdir 
)
inline

◆ set_step() [2/2]

void C_OUTLINE::set_step ( int16_t  stepindex,
DIR128  stepdir 
)
inline

◆ start_pos()

const ICOORD& C_OUTLINE::start_pos ( ) const
inline

◆ step()

ICOORD C_OUTLINE::step ( int  index) const
inline

◆ step_dir()

DIR128 C_OUTLINE::step_dir ( int  index) const
inline

◆ step_mem()

int C_OUTLINE::step_mem ( ) const
inlineprivate

◆ sub_pixel_pos_at_index()

FCOORD C_OUTLINE::sub_pixel_pos_at_index ( const ICOORD pos,
int  index 
) const
inline

◆ turn_direction()

int16_t C_OUTLINE::turn_direction ( ) const

C_OUTLINE::turn_direction

Returns
the sum direction delta of the outline.

◆ winding_number()

int16_t C_OUTLINE::winding_number ( ICOORD  testpt) const

Member Data Documentation

◆ box

TBOX C_OUTLINE::box
private

◆ children

C_OUTLINE_LIST C_OUTLINE::children
private

◆ flags

BITS16 C_OUTLINE::flags
private

◆ kMaxOutlineLength

const int C_OUTLINE::kMaxOutlineLength = 16000
static

◆ offsets

EdgeOffset* C_OUTLINE::offsets
private

◆ start

ICOORD C_OUTLINE::start
private

◆ step_coords

ICOORD C_OUTLINE::step_coords
staticprivate
Initial value:
= {
ICOORD (-1, 0), ICOORD (0, -1), ICOORD (1, 0), ICOORD (0, 1)
}

◆ stepcount

int16_t C_OUTLINE::stepcount
private

◆ steps

uint8_t* C_OUTLINE::steps
private

The documentation for this class was generated from the following files: