src/textord/textlineprojection.cpp
int TextlineProjection::BestMeanGradientInRow(const DENORM *denorm, int16_t min_x, int16_t max_x,
                                              int16_t y, bool best_is_max) const {
  TPOINT start_pt(min_x, y);
  TPOINT end_pt(max_x, y);
  int upper = MeanPixelsInLineSegment(denorm, -2, start_pt, end_pt);
  int lower = MeanPixelsInLineSegment(denorm, 2, start_pt, end_pt);
  int best_gradient = lower - upper;
  upper = MeanPixelsInLineSegment(denorm, -1, start_pt, end_pt);
  lower = MeanPixelsInLineSegment(denorm, 3, start_pt, end_pt);
  int gradient = lower - upper;
  if ((gradient > best_gradient) == best_is_max) {
    best_gradient = gradient;
  }
  upper = MeanPixelsInLineSegment(denorm, -3, start_pt, end_pt);
  lower = MeanPixelsInLineSegment(denorm, 1, start_pt, end_pt);
  gradient = lower - upper;
  if ((gradient > best_gradient) == best_is_max) {
    best_gradient = gradient;
  }
  return best_gradient;
}
// Helper returns the mean gradient value for the horizontal row at the given
// y, (in the external coordinates) by subtracting the mean of the transformed
// row 2 pixels above from the mean of the transformed row 2 pixels below.
// This gives a positive value for a good top edge and negative for bottom.
// Returns the best result out of +2/-2, +3/-1, +1/-3 pixels from the edge.
Helper returns the mean gradient value for the horizontal row at the given
y, (in the external coordinates) by subtracting the mean of the transformed
row 2 pixels above from the mean of the transformed row 2 pixels below.
This gives a positive value for a good top edge and negative for bottom.
Returns the best result out of +2/-2, +3/-1, +1/-3 pixels from the edge.
Helper returns the mean gradient value for the horizontal row at the given y ( in the external coordinates ) by subtracting the mean of the transformed row 2 pixels above from the mean of the transformed row 2 pixels below . This gives a positive value for a good top edge and negative for bottom . Returns the best result out of + 2 / - 2 + 3 / - 1 + 1 / - 3 pixels from the edge .
int TextlineProjection::BestMeanGradientInRow(const DENORM *denorm, int16_t min_x, int16_t max_x,
                                              int16_t y, bool best_is_max) const {
  TPOINT start_pt(min_x, y);
  TPOINT end_pt(max_x, y);
  int upper = MeanPixelsInLineSegment(denorm, -2, start_pt, end_pt);
  int lower = MeanPixelsInLineSegment(denorm, 2, start_pt, end_pt);
  int best_gradient = lower - upper;
  upper = MeanPixelsInLineSegment(denorm, -1, start_pt, end_pt);
  lower = MeanPixelsInLineSegment(denorm, 3, start_pt, end_pt);
  int gradient = lower - upper;
  if ((gradient > best_gradient) == best_is_max) {
    best_gradient = gradient;
  }
  upper = MeanPixelsInLineSegment(denorm, -3, start_pt, end_pt);
  lower = MeanPixelsInLineSegment(denorm, 1, start_pt, end_pt);
  gradient = lower - upper;
  if ((gradient > best_gradient) == best_is_max) {
    best_gradient = gradient;
  }
  return best_gradient;
}
int TextlineProjection :: BestMeanGradientInRow ( const DENORM * denorm , int16_t min_x , int16_t max_x , int16_t y , bool best_is_max ) const { TPOINT start_pt ( min_x , y ) ; TPOINT end_pt ( max_x , y ) ; int upper = MeanPixelsInLineSegment ( denorm , -2 , start_pt , end_pt ) ; int lower = MeanPixelsInLineSegment ( denorm , 2 , start_pt , end_pt ) ; int best_gradient = lower - upper ; upper = MeanPixelsInLineSegment ( denorm , -1 , start_pt , end_pt ) ; lower = MeanPixelsInLineSegment ( denorm , 3 , start_pt , end_pt ) ; int gradient = lower - upper ; if ( ( gradient > best_gradient ) == best_is_max ) { best_gradient = gradient ; } upper = MeanPixelsInLineSegment ( denorm , -3 , start_pt , end_pt ) ; lower = MeanPixelsInLineSegment ( denorm , 1 , start_pt , end_pt ) ; gradient = lower - upper ; if ( ( gradient > best_gradient ) == best_is_max ) { best_gradient = gradient ; } return best_gradient ; }
Helper returns the mean gradient value for the horizontal row at the given
y, (in the external coordinates) by subtracting the mean of the transformed
row 2 pixels above from the mean of the transformed row 2 pixels below.
Helper returns the mean gradient value for the horizontal row at the given y ( in the external coordinates ) by subtracting the mean of the transformed row 2 pixels above from the mean of the transformed row 2 pixels below .