@@ -80,7 +80,7 @@ const int kMaxColorDistance = 900;
80
80
// Vertical is the direction of logical vertical on the possibly skewed image.
81
81
ColPartition::ColPartition (BlobRegionType blob_type, const ICOORD& vertical)
82
82
: left_margin_(-INT32_MAX), right_margin_(INT32_MAX),
83
- median_bottom_ (INT32_MAX), median_top_(-INT32_MAX), median_size_ (0 ),
83
+ median_bottom_ (INT32_MAX), median_top_(-INT32_MAX), median_height_ (0 ),
84
84
median_left_(INT32_MAX), median_right_(-INT32_MAX), median_width_(0 ),
85
85
blob_type_(blob_type), flow_(BTFT_NONE), good_blob_score_(0 ),
86
86
good_width_(false ), good_column_(false ),
@@ -163,7 +163,7 @@ ColPartition* ColPartition::MakeLinePartition(BlobRegionType blob_type,
163
163
part->bounding_box_ = TBOX (left, bottom, right, top);
164
164
part->median_bottom_ = bottom;
165
165
part->median_top_ = top;
166
- part->median_size_ = top - bottom;
166
+ part->median_height_ = top - bottom;
167
167
part->median_left_ = left;
168
168
part->median_right_ = right;
169
169
part->median_width_ = right - left;
@@ -416,7 +416,7 @@ bool ColPartition::MatchingSizes(const ColPartition& other) const {
416
416
if (blob_type_ == BRT_VERT_TEXT || other.blob_type_ == BRT_VERT_TEXT)
417
417
return !TabFind::DifferentSizes (median_width_, other.median_width_ );
418
418
else
419
- return !TabFind::DifferentSizes (median_size_ , other.median_size_ );
419
+ return !TabFind::DifferentSizes (median_height_ , other.median_height_ );
420
420
}
421
421
422
422
// Returns true if there is no tabstop violation in merging this and other.
@@ -904,14 +904,14 @@ void ColPartition::ComputeLimits() {
904
904
blob_type () == BRT_POLYIMAGE) {
905
905
median_top_ = bounding_box_.top ();
906
906
median_bottom_ = bounding_box_.bottom ();
907
- median_size_ = bounding_box_.height ();
907
+ median_height_ = bounding_box_.height ();
908
908
median_left_ = bounding_box_.left ();
909
909
median_right_ = bounding_box_.right ();
910
910
median_width_ = bounding_box_.width ();
911
911
} else {
912
912
STATS top_stats (bounding_box_.bottom (), bounding_box_.top () + 1 );
913
913
STATS bottom_stats (bounding_box_.bottom (), bounding_box_.top () + 1 );
914
- STATS size_stats (0 , bounding_box_.height () + 1 );
914
+ STATS height_stats (0 , bounding_box_.height () + 1 );
915
915
STATS left_stats (bounding_box_.left (), bounding_box_.right () + 1 );
916
916
STATS right_stats (bounding_box_.left (), bounding_box_.right () + 1 );
917
917
STATS width_stats (0 , bounding_box_.width () + 1 );
@@ -922,15 +922,15 @@ void ColPartition::ComputeLimits() {
922
922
int area = box.area ();
923
923
top_stats.add (box.top (), area);
924
924
bottom_stats.add (box.bottom (), area);
925
- size_stats .add (box.height (), area);
925
+ height_stats .add (box.height (), area);
926
926
left_stats.add (box.left (), area);
927
927
right_stats.add (box.right (), area);
928
928
width_stats.add (box.width (), area);
929
929
}
930
930
}
931
931
median_top_ = static_cast <int >(top_stats.median () + 0.5 );
932
932
median_bottom_ = static_cast <int >(bottom_stats.median () + 0.5 );
933
- median_size_ = static_cast <int >(size_stats .median () + 0.5 );
933
+ median_height_ = static_cast <int >(height_stats .median () + 0.5 );
934
934
median_left_ = static_cast <int >(left_stats.median () + 0.5 );
935
935
median_right_ = static_cast <int >(right_stats.median () + 0.5 );
936
936
median_width_ = static_cast <int >(width_stats.median () + 0.5 );
@@ -1492,23 +1492,23 @@ void ColPartition::LineSpacingBlocks(const ICOORD& bleft, const ICOORD& tright,
1492
1492
" sizes %d %d %d\n " ,
1493
1493
part->top_spacing (), part->bottom_spacing (),
1494
1494
next_part->top_spacing (), next_part->bottom_spacing (),
1495
- part->median_size (), next_part->median_size (),
1496
- third_part != nullptr ? third_part->median_size () : 0 );
1495
+ part->median_height (), next_part->median_height (),
1496
+ third_part != nullptr ? third_part->median_height () : 0 );
1497
1497
}
1498
1498
// We can only consider adding the next line to the block if the sizes
1499
1499
// match and the lines are close enough for their size.
1500
1500
if (part->SizesSimilar (*next_part) &&
1501
- next_part->median_size () * kMaxSameBlockLineSpacing >
1501
+ next_part->median_height () * kMaxSameBlockLineSpacing >
1502
1502
part->bottom_spacing () &&
1503
- part->median_size () * kMaxSameBlockLineSpacing >
1503
+ part->median_height () * kMaxSameBlockLineSpacing >
1504
1504
part->top_spacing ()) {
1505
1505
// Even now, we can only add it as long as the third line doesn't
1506
1506
// match in the same way and have a smaller bottom spacing.
1507
1507
if (third_part == nullptr ||
1508
1508
!next_part->SizesSimilar (*third_part) ||
1509
- third_part->median_size () * kMaxSameBlockLineSpacing <=
1509
+ third_part->median_height () * kMaxSameBlockLineSpacing <=
1510
1510
next_part->bottom_spacing () ||
1511
- next_part->median_size () * kMaxSameBlockLineSpacing <=
1511
+ next_part->median_height () * kMaxSameBlockLineSpacing <=
1512
1512
next_part->top_spacing () ||
1513
1513
next_part->bottom_spacing () > part->bottom_spacing ()) {
1514
1514
// Add to the current block.
@@ -1532,7 +1532,7 @@ void ColPartition::LineSpacingBlocks(const ICOORD& bleft, const ICOORD& tright,
1532
1532
tprintf (" Spacings equal: upper:%d/%d, lower:%d/%d, median:%d/%d\n " ,
1533
1533
part->top_spacing (), part->bottom_spacing (),
1534
1534
next_part->top_spacing (), next_part->bottom_spacing (),
1535
- part->median_size (), next_part->median_size ());
1535
+ part->median_height (), next_part->median_height ());
1536
1536
}
1537
1537
}
1538
1538
}
@@ -1647,7 +1647,7 @@ TO_BLOCK* ColPartition::MakeBlock(const ICOORD& bleft, const ICOORD& tright,
1647
1647
// put the average spacing in each partition, so we can just take the
1648
1648
// linespacing from the first partition.
1649
1649
int line_spacing = part->bottom_spacing ();
1650
- if (line_spacing < part->median_size ())
1650
+ if (line_spacing < part->median_height ())
1651
1651
line_spacing = part->bounding_box ().height ();
1652
1652
ICOORDELT_LIST vertices;
1653
1653
ICOORDELT_IT vert_it (&vertices);
@@ -1715,7 +1715,7 @@ TO_BLOCK* ColPartition::MakeVerticalTextBlock(const ICOORD& bleft,
1715
1715
TO_ROW* ColPartition::MakeToRow () {
1716
1716
BLOBNBOX_C_IT blob_it (&boxes_);
1717
1717
TO_ROW* row = nullptr ;
1718
- int line_size = IsVerticalType () ? median_width_ : median_size_ ;
1718
+ int line_size = IsVerticalType () ? median_width_ : median_height_ ;
1719
1719
// Add all the blobs to a single TO_ROW.
1720
1720
for (; !blob_it.empty (); blob_it.forward ()) {
1721
1721
BLOBNBOX* blob = blob_it.extract ();
@@ -1746,7 +1746,7 @@ ColPartition* ColPartition::ShallowCopy() const {
1746
1746
sizeof (special_blobs_densities_));
1747
1747
part->median_bottom_ = median_bottom_;
1748
1748
part->median_top_ = median_top_;
1749
- part->median_size_ = median_size_ ;
1749
+ part->median_height_ = median_height_ ;
1750
1750
part->median_left_ = median_left_;
1751
1751
part->median_right_ = median_right_;
1752
1752
part->median_width_ = median_width_;
@@ -2398,15 +2398,15 @@ int ColPartition::BottomSpacingMargin(int resolution) const {
2398
2398
// Returns a suitable spacing margin that can be applied to tops of
2399
2399
// text lines, based on the resolution and the stored side_step_.
2400
2400
int ColPartition::TopSpacingMargin (int resolution) const {
2401
- return static_cast <int >(kMaxTopSpacingFraction * median_size_ + 0.5 ) +
2401
+ return static_cast <int >(kMaxTopSpacingFraction * median_height_ + 0.5 ) +
2402
2402
BottomSpacingMargin (resolution);
2403
2403
}
2404
2404
2405
2405
// Returns true if the median text sizes of this and other agree to within
2406
2406
// a reasonable multiplicative factor.
2407
2407
bool ColPartition::SizesSimilar (const ColPartition& other) const {
2408
- return median_size_ <= other.median_size_ * kMaxSizeRatio &&
2409
- other.median_size_ <= median_size_ * kMaxSizeRatio ;
2408
+ return median_height_ <= other.median_height_ * kMaxSizeRatio &&
2409
+ other.median_height_ <= median_height_ * kMaxSizeRatio ;
2410
2410
}
2411
2411
2412
2412
// Helper updates margin_left and margin_right, being the bounds of the left
0 commit comments