tesseract  4.00.00dev
quspline.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: quspline.h (Formerly qspline.h)
3  * Description: Code for the QSPLINE class.
4  * Author: Ray Smith
5  * Created: Tue Oct 08 17:16:12 BST 1991
6  *
7  * (C) Copyright 1991, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef QUSPLINE_H
21 #define QUSPLINE_H
22 
23 #include "quadratc.h"
24 #include "serialis.h"
25 #include "memry.h"
26 #include "rect.h"
27 
28 class ROW;
29 struct Pix;
30 
31 class QSPLINE
32 {
33  friend void make_first_baseline(TBOX *,
34  int,
35  int *,
36  int *,
37  QSPLINE *,
38  QSPLINE *,
39  float);
40  friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float);
41  friend void tweak_row_baseline(ROW *, double, double);
42  public:
43  QSPLINE() { //empty constructor
44  segments = 0;
45  xcoords = NULL; //everything empty
46  quadratics = NULL;
47  }
48  QSPLINE( //copy constructor
49  const QSPLINE &src);
50  QSPLINE( //constructor
51  inT32 count, //number of segments
52  inT32 *xstarts, //segment starts
53  double *coeffs); //coefficients
54  ~QSPLINE (); //destructor
55  QSPLINE ( //least squares fit
56  int xstarts[], //spline boundaries
57  int segcount, //no of segments
58  int xcoords[], //points to fit
59  int ycoords[], int blobcount,//no of coords
60  int degree); //function
61 
62  double step( //step change
63  double x1, //between coords
64  double x2);
65  double y( //evaluate
66  double x) const; //at x
67 
68  void move( // reposition spline
69  ICOORD vec); // by vector
70  BOOL8 overlap( //test overlap
71  QSPLINE *spline2, //2 cannot be smaller
72  double fraction); //by more than this
73  void extrapolate( //linear extrapolation
74  double gradient, //gradient to use
75  int left, //new left edge
76  int right); //new right edge
77 
78 #ifndef GRAPHICS_DISABLED
79  void plot( //draw it
80  ScrollView* window, //in window
81  ScrollView::Color colour) const; //in colour
82 #endif
83 
84  // Paint the baseline over pix. If pix has depth of 32, then the line will
85  // be painted in red. Otherwise it will be painted in black.
86  void plot(Pix* pix) const;
87 
89  const QSPLINE & source); //from this
90 
91  private:
92 
93  inT32 spline_index( //binary search
94  double x) const; //for x
95  inT32 segments; //no of segments
96  inT32 *xcoords; //no of coords
97  QUAD_COEFFS *quadratics; //spline pieces
98 };
99 #endif
void move(ICOORD vec)
Definition: quspline.cpp:259
int32_t inT32
Definition: host.h:38
QSPLINE()
Definition: quspline.h:43
void plot(ScrollView *window, ScrollView::Color colour) const
Definition: quspline.cpp:363
friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float)
~QSPLINE()
Definition: quspline.cpp:151
friend void tweak_row_baseline(ROW *, double, double)
Definition: tordmain.cpp:885
unsigned char BOOL8
Definition: host.h:44
double y(double x) const
Definition: quspline.cpp:217
BOOL8 overlap(QSPLINE *spline2, double fraction)
Definition: quspline.cpp:280
double step(double x1, double x2)
Definition: quspline.cpp:192
Definition: rect.h:30
QSPLINE & operator=(const QSPLINE &source)
Definition: quspline.cpp:170
Definition: ocrrow.h:32
int count(LIST var_list)
Definition: oldlist.cpp:103
void extrapolate(double gradient, int left, int right)
Definition: quspline.cpp:306
friend void make_first_baseline(TBOX *, int, int *, int *, QSPLINE *, QSPLINE *, float)
integer coordinate
Definition: points.h:30