textord/pitsync1.h File Reference

#include "elst.h"
#include "clst.h"
#include "blobbox.h"
#include "varable.h"
#include "statistc.h"
#include "pithsync.h"
#include "notdll.h"

Go to the source code of this file.

Classes

Functions

Variables


Function Documentation

void make_illegal_segment ( FPSEGPT_LIST *  prev_list,
BOX  blob_box,
BLOBNBOX_IT  blob_it,
INT16  region_index,
INT16  pitch,
INT16  pitch_error,
FPSEGPT_LIST *  seg_list 
)

Find segmentation

Make a fake set of chop points due to having no legal places.

Definition at line 356 of file pitsync1.cpp.

References ASSERT_HOST, box_next(), FPSEGPT::cost_function(), FPSEGPT::fake_count, FALSE, BOX::left(), MAX_FLOAT32, NULL, FPSEGPT::position(), FPSEGPT::previous(), BOX::right(), and TRUE.

Referenced by check_pitch_sync().

00364                            {
00365   INT16 x;                       //current coord
00366   INT16 min_x = 0;               //in this region
00367   INT16 max_x = 0;
00368   INT16 offset;                  //dist to edge
00369   FPSEGPT *segpt;                //segment point
00370   FPSEGPT *prevpt;               //previous point
00371   float best_cost;               //best path
00372   FPSEGPT_IT segpt_it = seg_list;//iterator
00373                                  //previous points
00374   FPSEGPT_IT prevpt_it = prev_list;
00375 
00376   best_cost = MAX_FLOAT32;
00377   for (prevpt_it.mark_cycle_pt (); !prevpt_it.cycled_list ();
00378   prevpt_it.forward ()) {
00379     prevpt = prevpt_it.data ();
00380     if (prevpt->cost_function () < best_cost) {
00381                                  //find least
00382       best_cost = prevpt->cost_function ();
00383       min_x = prevpt->position ();
00384       max_x = min_x;             //limits on coords
00385     }
00386     else if (prevpt->cost_function () == best_cost) {
00387       max_x = prevpt->position ();
00388     }
00389   }
00390   min_x += pitch - pitch_error;
00391   max_x += pitch + pitch_error;
00392   for (x = min_x; x <= max_x; x++) {
00393     while (x > blob_box.right ()) {
00394       blob_box = box_next (&blob_it);
00395     }
00396     offset = x - blob_box.left ();
00397     if (blob_box.right () - x < offset)
00398       offset = blob_box.right () - x;
00399     segpt = new FPSEGPT (x, FALSE, offset,
00400       region_index, pitch, pitch_error, prev_list);
00401     if (segpt->previous () != NULL) {
00402       ASSERT_HOST (offset >= 0);
00403       fprintf (stderr, "made fake at %d\n", x);
00404                                  //make one up
00405       segpt_it.add_after_then_move (segpt);
00406       segpt->faked = TRUE;
00407       segpt->fake_count++;
00408     }
00409     else
00410       delete segpt;
00411   }
00412 }

void vertical_blob_projection ( PBLOB blob,
STATS stats 
)

Project outlines.

Compute the vertical projection of a blob from its outlines and add to the given STATS.

Definition at line 544 of file blobbox.cpp.

References PBLOB::out_list(), and vertical_outline_projection().

Referenced by TO_ROW::compute_vertical_projection().

00547                                {
00548                                  //outlines of blob
00549   OUTLINE_IT out_it = blob->out_list ();
00550 
00551   for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
00552     vertical_outline_projection (out_it.data (), stats);
00553   }
00554 }

void vertical_cblob_projection ( C_BLOB blob,
STATS stats 
)

Project Outlines.

Compute the vertical projection of a cblob from its outlines and add to the given STATS.

Definition at line 650 of file blobbox.cpp.

References C_BLOB::out_list(), and vertical_coutline_projection().

Referenced by TO_ROW::compute_vertical_projection().

00653                                 {
00654                                  //outlines of blob
00655   C_OUTLINE_IT out_it = blob->out_list ();
00656 
00657   for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
00658     vertical_coutline_projection (out_it.data (), stats);
00659   }
00660 }

void vertical_coutline_projection ( C_OUTLINE outline,
STATS stats 
)

Project Outlines.

Compute the vertical projection of a outline from its outlines and add to the given STATS.

Definition at line 669 of file blobbox.cpp.

References STATS::add(), vertical_coutline_projection(), and ICOORD::y().

Referenced by vertical_cblob_projection(), and vertical_coutline_projection().

00672                                    {
00673   ICOORD pos;                    //current point
00674   ICOORD step;                   //edge step
00675   INT32 length;                  //of outline
00676   INT16 stepindex;               //current step
00677   C_OUTLINE_IT out_it = outline->child ();
00678 
00679   pos = outline->start_pos ();
00680   length = outline->pathlength ();
00681   for (stepindex = 0; stepindex < length; stepindex++) {
00682     step = outline->step (stepindex);
00683     if (step.x () > 0) {
00684       if (pitsync_projection_fix)
00685         stats->add (pos.x (), -pos.y ());
00686       else
00687         stats->add (pos.x (), pos.y ());
00688     }
00689     else if (step.x () < 0) {
00690       if (pitsync_projection_fix)
00691         stats->add (pos.x () - 1, pos.y ());
00692       else
00693         stats->add (pos.x () - 1, -pos.y ());
00694     }
00695     pos += step;
00696   }
00697 
00698   for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
00699     vertical_coutline_projection (out_it.data (), stats);
00700   }
00701 }

void vertical_outline_projection ( OUTLINE outline,
STATS stats 
)

Project Outlines.

Compute the vertical projection of a outline from its outlines and add to the given STATS.

Definition at line 563 of file blobbox.cpp.

References STATS::add(), f, POLYPT::vec, and vertical_outline_projection().

Referenced by vertical_blob_projection(), and vertical_outline_projection().

00566                                   {
00567   POLYPT *polypt;                //current point
00568   INT32 xcoord;                  //current pixel coord
00569   float end_x;                   //end of vec
00570   POLYPT_IT poly_it = outline->polypts ();
00571   OUTLINE_IT out_it = outline->child ();
00572   float ymean;                   //amount to add
00573   float width;                   //amount of x
00574 
00575   for (poly_it.mark_cycle_pt (); !poly_it.cycled_list (); poly_it.forward ()) {
00576     polypt = poly_it.data ();
00577     end_x = polypt->pos.x () + polypt->vec.x ();
00578     if (polypt->vec.x () > 0) {
00579       for (xcoord = (INT32) floor (polypt->pos.x ());
00580       xcoord < end_x; xcoord++) {
00581         if (polypt->pos.x () < xcoord) {
00582           width = (float) xcoord;
00583           ymean =
00584             polypt->vec.y () * (xcoord -
00585             polypt->pos.x ()) / polypt->vec.x () +
00586             polypt->pos.y ();
00587         }
00588         else {
00589           width = polypt->pos.x ();
00590           ymean = polypt->pos.y ();
00591         }
00592         if (end_x > xcoord + 1) {
00593           width -= xcoord + 1;
00594           ymean +=
00595             polypt->vec.y () * (xcoord + 1 -
00596             polypt->pos.x ()) / polypt->vec.x () +
00597             polypt->pos.y ();
00598         }
00599         else {
00600           width -= end_x;
00601           ymean += polypt->pos.y () + polypt->vec.y ();
00602         }
00603         ymean = ymean * width / 2;
00604         stats->add (xcoord, (INT32) floor (ymean + 0.5));
00605       }
00606     }
00607     else if (polypt->vec.x () < 0) {
00608       for (xcoord = (INT32) floor (end_x);
00609       xcoord < polypt->pos.x (); xcoord++) {
00610         if (polypt->pos.x () > xcoord + 1) {
00611           width = xcoord + 1.0f;
00612           ymean =
00613             polypt->vec.y () * (xcoord + 1 -
00614             polypt->pos.x ()) / polypt->vec.x () +
00615             polypt->pos.y ();
00616         }
00617         else {
00618           width = polypt->pos.x ();
00619           ymean = polypt->pos.y ();
00620         }
00621         if (end_x < xcoord) {
00622           width -= xcoord;
00623           ymean +=
00624             polypt->vec.y () * (xcoord -
00625             polypt->pos.x ()) / polypt->vec.x () +
00626             polypt->pos.y ();
00627         }
00628         else {
00629           width -= end_x;
00630           ymean += polypt->pos.y () + polypt->vec.y ();
00631         }
00632         ymean = ymean * width / 2;
00633         stats->add (xcoord, (INT32) floor (ymean + 0.5));
00634       }
00635     }
00636   }
00637 
00638   for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
00639     vertical_outline_projection (out_it.data (), stats);
00640   }
00641 }

INT16 vertical_torow_projection ( TO_ROW row,
STATS projection 
)


Variable Documentation

INT16 blob_count

Definition at line 126 of file pitsync1.h.

Referenced by compare_states(), compute_page_skew(), compute_pitch_sd(), compute_pitch_sd2(), compute_row_descdrop(), compute_row_xheight(), median_block_xheight(), plot_word_decisions(), print_pitch_sd(), tweak_row_baseline(), and worst_noise_blob().

INT16 INT16 pitch

Definition at line 126 of file pitsync1.h.

Referenced by find_row_pitch(), and try_doc_fixed().

INT16 INT16 INT16 pitch_error

Definition at line 126 of file pitsync1.h.

INT16 INT16 INT16 STATS* projection

Definition at line 126 of file pitsync1.h.

Referenced by check_pitch_sync(), check_pitch_sync2(), check_pitch_sync3(), compute_pitch_sd(), compute_pitch_sd2(), plot_fp_cells(), print_pitch_sd(), test_underline(), try_doc_fixed(), tune_row_pitch(), and tune_row_pitch2().

INT16 INT16 INT16 STATS FPSEGPT_LIST* seg_list

Definition at line 126 of file pitsync1.h.

Referenced by compute_pitch_sd(), compute_pitch_sd2(), plot_fp_cells(), and print_pitch_sd().


Generated on Wed Feb 28 19:49:25 2007 for Tesseract by  doxygen 1.5.1