47
47
#include "structures.h"
48
48
#include "werd.h"
49
49
50
+ #include <algorithm>
51
+
50
52
using tesseract ::CCStruct ;
51
53
52
54
// A Vector representing the "vertical" direction when measuring the
@@ -587,10 +589,10 @@ static void SegmentLLSQ(const FCOORD& pt1, const FCOORD& pt2,
587
589
LLSQ * accumulator ) {
588
590
FCOORD step (pt2 );
589
591
step -= pt1 ;
590
- int xstart = IntCastRounded (MIN (pt1 .x (), pt2 .x ()));
591
- int xend = IntCastRounded (MAX (pt1 .x (), pt2 .x ()));
592
- int ystart = IntCastRounded (MIN (pt1 .y (), pt2 .y ()));
593
- int yend = IntCastRounded (MAX (pt1 .y (), pt2 .y ()));
592
+ int xstart = IntCastRounded (std :: min (pt1 .x (), pt2 .x ()));
593
+ int xend = IntCastRounded (std :: max (pt1 .x (), pt2 .x ()));
594
+ int ystart = IntCastRounded (std :: min (pt1 .y (), pt2 .y ()));
595
+ int yend = IntCastRounded (std :: max (pt1 .y (), pt2 .y ()));
594
596
if (xstart == xend && ystart == yend ) return ; // Nothing to do.
595
597
double weight = step .length () / (xend - xstart + yend - ystart );
596
598
// Compute and save the y-position at the middle of each x-step.
@@ -616,14 +618,14 @@ static void SegmentCoords(const FCOORD& pt1, const FCOORD& pt2,
616
618
GenericVector < GenericVector < int > > * y_coords ) {
617
619
FCOORD step (pt2 );
618
620
step -= pt1 ;
619
- int start = ClipToRange (IntCastRounded (MIN (pt1 .x (), pt2 .x ())), 0 , x_limit );
620
- int end = ClipToRange (IntCastRounded (MAX (pt1 .x (), pt2 .x ())), 0 , x_limit );
621
+ int start = ClipToRange (IntCastRounded (std :: min (pt1 .x (), pt2 .x ())), 0 , x_limit );
622
+ int end = ClipToRange (IntCastRounded (std :: max (pt1 .x (), pt2 .x ())), 0 , x_limit );
621
623
for (int x = start ; x < end ; ++ x ) {
622
624
int y = IntCastRounded (pt1 .y () + step .y () * (x + 0.5 - pt1 .x ()) / step .x ());
623
625
(* y_coords )[x ].push_back (y );
624
626
}
625
- start = ClipToRange (IntCastRounded (MIN (pt1 .y (), pt2 .y ())), 0 , y_limit );
626
- end = ClipToRange (IntCastRounded (MAX (pt1 .y (), pt2 .y ())), 0 , y_limit );
627
+ start = ClipToRange (IntCastRounded (std :: min (pt1 .y (), pt2 .y ())), 0 , y_limit );
628
+ end = ClipToRange (IntCastRounded (std :: max (pt1 .y (), pt2 .y ())), 0 , y_limit );
627
629
for (int y = start ; y < end ; ++ y ) {
628
630
int x = IntCastRounded (pt1 .x () + step .x () * (y + 0.5 - pt1 .y ()) / step .y ());
629
631
(* x_coords )[y ].push_back (x );
@@ -636,24 +638,24 @@ static void SegmentCoords(const FCOORD& pt1, const FCOORD& pt2,
636
638
static void SegmentBBox (const FCOORD & pt1 , const FCOORD & pt2 , TBOX * bbox ) {
637
639
FCOORD step (pt2 );
638
640
step -= pt1 ;
639
- int x1 = IntCastRounded (MIN (pt1 .x (), pt2 .x ()));
640
- int x2 = IntCastRounded (MAX (pt1 .x (), pt2 .x ()));
641
+ int x1 = IntCastRounded (std :: min (pt1 .x (), pt2 .x ()));
642
+ int x2 = IntCastRounded (std :: max (pt1 .x (), pt2 .x ()));
641
643
if (x2 > x1 ) {
642
644
int y1 = IntCastRounded (pt1 .y () + step .y () * (x1 + 0.5 - pt1 .x ()) /
643
645
step .x ());
644
646
int y2 = IntCastRounded (pt1 .y () + step .y () * (x2 - 0.5 - pt1 .x ()) /
645
647
step .x ());
646
- TBOX point (x1 , MIN (y1 , y2 ), x2 , MAX (y1 , y2 ));
648
+ TBOX point (x1 , std :: min (y1 , y2 ), x2 , std :: max (y1 , y2 ));
647
649
* bbox += point ;
648
650
}
649
- int y1 = IntCastRounded (MIN (pt1 .y (), pt2 .y ()));
650
- int y2 = IntCastRounded (MAX (pt1 .y (), pt2 .y ()));
651
+ int y1 = IntCastRounded (std :: min (pt1 .y (), pt2 .y ()));
652
+ int y2 = IntCastRounded (std :: max (pt1 .y (), pt2 .y ()));
651
653
if (y2 > y1 ) {
652
654
int x1 = IntCastRounded (pt1 .x () + step .x () * (y1 + 0.5 - pt1 .y ()) /
653
655
step .y ());
654
656
int x2 = IntCastRounded (pt1 .x () + step .x () * (y2 - 0.5 - pt1 .y ()) /
655
657
step .y ());
656
- TBOX point (MIN (x1 , x2 ), y1 , MAX (x1 , x2 ), y2 );
658
+ TBOX point (std :: min (x1 , x2 ), y1 , std :: max (x1 , x2 ), y2 );
657
659
* bbox += point ;
658
660
}
659
661
}
@@ -956,7 +958,7 @@ bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
956
958
int min_prod2 , max_prod2 ;
957
959
outline2 -> MinMaxCrossProduct (vertical , & min_prod2 , & max_prod2 );
958
960
int mid_gap = abs (mid_prod2 - mid_prod1 );
959
- int overlap = MIN (max_prod1 , max_prod2 ) - MAX (min_prod1 , min_prod2 );
961
+ int overlap = std :: min (max_prod1 , max_prod2 ) - std :: max (min_prod1 , min_prod2 );
960
962
if (mid_gap - overlap / 4 > max_gap ) {
961
963
max_gap = mid_gap - overlap / 4 ;
962
964
* location = mid_pt1 ;
0 commit comments