wordrec/gradechop.h File Reference

#include "seam.h"

Go to the source code of this file.

Defines

Typedefs

Functions

Variables


Define Documentation

#define partial_split_priority ( split   ) 

Value:

(grade_split_length   (split) +      \
   grade_sharpness      (split))       \
Assign a priority to this split based on the features that it has.

Grade it according to the different rating schemes and return the value of its goodness.

Definition at line 53 of file gradechop.h.

Referenced by try_point_pairs(), and try_vertical_splits().

#define split_bounds_overlap ( split,
outline   ) 

Value:

(outline->topleft.x  <= max (split->point1->pos.x,split->point2->pos.x) && \
   outline->botright.x >= min (split->point1->pos.x,split->point2->pos.x) && \
   outline->botright.y <= max (split->point1->pos.y,split->point2->pos.y) && \
   outline->topleft.y  >= min (split->point1->pos.y,split->point2->pos.y))
Check to see if this split might overlap with this outline.

Return TRUE if there is a positive overlap in the bounding boxes of the two.

Definition at line 64 of file gradechop.h.

Referenced by constrained_split().


Typedef Documentation

BOUNDS_RECT

Holds array of points, coordinates of a bounding rectangle.

Definition at line 35 of file gradechop.h.


Function Documentation

PRIORITY full_split_priority ( SPLIT split,
INT16  xmin,
INT16  xmax 
)

Assign a priority to this split based on the features that it has.

Part of the priority has already been calculated so just return the additional amount for the bounding box type information.

Definition at line 63 of file gradechop.cpp.

References grade_center_of_blob(), grade_overlap(), grade_width_change(), max, min, split_record::point1, split_record::point2, and set_outline_bounds().

Referenced by seam_priority().

00063                                                                    { 
00064   BOUNDS_RECT rect;
00065 
00066   set_outline_bounds (split->point1, split->point2, rect);
00067 
00068   if (xmin < min (rect[0], rect[2]) && xmax > max (rect[1], rect[3]))
00069     return (999.0);
00070 
00071   return (grade_overlap (rect) +
00072     grade_center_of_blob (rect) + grade_width_change (rect));
00073 }

PRIORITY grade_center_of_blob ( register BOUNDS_RECT  rect  ) 

Return a grade for the a split.

Rank it on closeness to the center of the original blob

Definition at line 84 of file gradechop.cpp.

References CENTER_GRADE_CAP, center_knob, max, and min.

Referenced by full_split_priority().

00084                                                          { 
00085   register PRIORITY grade;
00086 
00087   grade = (rect[1] - rect[0]) - (rect[3] - rect[2]);
00088   if (grade < 0)
00089     grade = -grade;
00090 
00091   grade *= center_knob;
00092   grade = min (CENTER_GRADE_CAP, grade);
00093   return (max (0.0, grade));
00094 }

PRIORITY grade_overlap ( register BOUNDS_RECT  rect  ) 

Return a grade for this split for the overlap of the resultant blobs.

Definition at line 104 of file gradechop.cpp.

References max, min, and overlap_knob.

Referenced by full_split_priority().

00104                                                   { 
00105   register PRIORITY grade;
00106   register INT16 width1;
00107   register INT16 width2;
00108   register INT16 overlap;
00109 
00110   width1 = rect[3] - rect[2];
00111   width2 = rect[1] - rect[0];
00112 
00113   overlap = min (rect[1], rect[3]) - max (rect[0], rect[2]);
00114   width1 = min (width1, width2);
00115   if (overlap == width1)
00116     return (100.0);              /* Total overlap */
00117 
00118   width1 = 2 * overlap - width1; /* Extra penalty for too */
00119   overlap += max (0, width1);    /* much overlap */
00120 
00121   grade = overlap * overlap_knob;
00122 
00123   return (max (0.0, grade));
00124 }

PRIORITY grade_sharpness ( register SPLIT split  ) 

Return a grade for the sharpness of this split.

Definition at line 157 of file gradechop.cpp.

References point_priority(), and sharpness_knob.

00157                                                 { 
00158   register PRIORITY grade;
00159 
00160   grade = point_priority (split->point1) + point_priority (split->point2);
00161 
00162   if (grade < -360.0)
00163     grade = 0;
00164   else
00165     grade += 360.0;
00166 
00167   grade *= sharpness_knob;       /* Values 0 to -360 */
00168 
00169   return (grade);
00170 }

PRIORITY grade_split_length ( register SPLIT split  ) 

Return a grade for the length of this split.

Definition at line 134 of file gradechop.cpp.

References max, split_dist_knob, split_length, weighted_edgept_dist, and x_y_weight.

00134                                                    { 
00135   register PRIORITY grade;
00136   register float split_length;
00137 
00138   split_length = weighted_edgept_dist (split->point1, split->point2,
00139     x_y_weight);
00140 
00141   if (split_length <= 0)
00142     grade = 0;
00143   else
00144     grade = sqrt (split_length) * split_dist_knob;
00145 
00146   return (max (0.0, grade));
00147 }

PRIORITY grade_width_change ( register BOUNDS_RECT  rect  ) 

Return a grade for the change in width of the resultant blobs.

Definition at line 180 of file gradechop.cpp.

References max, min, and width_change_knob.

Referenced by full_split_priority().

00180                                                        { 
00181   register PRIORITY grade;
00182   register INT32 width1;
00183   register INT32 width2;
00184 
00185   width1 = rect[3] - rect[2];
00186   width2 = rect[1] - rect[0];
00187 
00188   grade = 20 - (max (rect[1], rect[3])
00189     - min (rect[0], rect[2]) - max (width1, width2));
00190 
00191   grade *= width_change_knob;
00192 
00193   return (max (0.0, grade));
00194 }

void set_outline_bounds ( register EDGEPT point1,
register EDGEPT point2,
BOUNDS_RECT  rect 
)

Set up the limits for the x coordinate of the outline.

Definition at line 201 of file gradechop.cpp.

References find_bounds_loop.

Referenced by full_split_priority().

00203                                           {
00204   register EDGEPT *this_point;
00205   register INT16 x_min;
00206   register INT16 x_max;
00207 
00208   find_bounds_loop(point1, point2, x_min, x_max); 
00209 
00210   rect[0] = x_min;
00211   rect[1] = x_max;
00212 
00213   find_bounds_loop(point2, point1, x_min, x_max); 
00214 
00215   rect[2] = x_min;
00216   rect[3] = x_max;
00217 }


Variable Documentation

int x_y_weight

Referenced by grade_split_length(), try_point_pairs(), and try_vertical_splits().


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