tesseract 4.1.1
Loading...
Searching...
No Matches
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 <cstdint> // for int32_t
24#include "scrollview.h" // for ScrollView, ScrollView::Color
25
26class ICOORD;
27class QUAD_COEFFS;
28class ROW;
29class TBOX;
30struct Pix;
31
33{
35 int,
36 int *,
37 int *,
38 QSPLINE *,
39 QSPLINE *,
40 float);
41 friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float);
42 friend void tweak_row_baseline(ROW *, double, double);
43 public:
44 QSPLINE() { //empty constructor
45 segments = 0;
46 xcoords = nullptr; //everything empty
47 quadratics = nullptr;
48 }
49 QSPLINE( //copy constructor
50 const QSPLINE &src);
51 QSPLINE( //constructor
52 int32_t count, //number of segments
53 int32_t *xstarts, //segment starts
54 double *coeffs); //coefficients
55 ~QSPLINE (); //destructor
56 QSPLINE ( //least squares fit
57 int xstarts[], //spline boundaries
58 int segcount, //no of segments
59 int xcoords[], //points to fit
60 int ycoords[], int blobcount,//no of coords
61 int degree); //function
62
63 double step( //step change
64 double x1, //between coords
65 double x2);
66 double y( //evaluate
67 double x) const; //at x
68
69 void move( // reposition spline
70 ICOORD vec); // by vector
71 bool overlap( //test overlap
72 QSPLINE* spline2, //2 cannot be smaller
73 double fraction); //by more than this
74 void extrapolate( //linear extrapolation
75 double gradient, //gradient to use
76 int left, //new left edge
77 int right); //new right edge
78
79#ifndef GRAPHICS_DISABLED
80 void plot( //draw it
81 ScrollView* window, //in window
82 ScrollView::Color colour) const; //in colour
83#endif
84
85 // Paint the baseline over pix. If pix has depth of 32, then the line will
86 // be painted in red. Otherwise it will be painted in black.
87 void plot(Pix* pix) const;
88
90 const QSPLINE & source); //from this
91
92 private:
93
94 int32_t spline_index( //binary search
95 double x) const; //for x
96 int32_t segments; //no of segments
97 int32_t *xcoords; //no of coords
98 QUAD_COEFFS *quadratics; //spline pieces
99};
100#endif
int count(LIST var_list)
Definition: oldlist.cpp:95
Definition: ocrrow.h:37
integer coordinate
Definition: points.h:32
void extrapolate(double gradient, int left, int right)
Definition: quspline.cpp:291
friend void make_first_baseline(TBOX *, int, int *, int *, QSPLINE *, QSPLINE *, float)
void move(ICOORD vec)
Definition: quspline.cpp:251
QSPLINE()
Definition: quspline.h:44
bool overlap(QSPLINE *spline2, double fraction)
Definition: quspline.cpp:272
double y(double x) const
Definition: quspline.cpp:209
~QSPLINE()
Definition: quspline.cpp:152
void plot(ScrollView *window, ScrollView::Color colour) const
Definition: quspline.cpp:347
QSPLINE & operator=(const QSPLINE &source)
Definition: quspline.cpp:164
double step(double x1, double x2)
Definition: quspline.cpp:184
friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float)
friend void tweak_row_baseline(ROW *, double, double)
Definition: tordmain.cpp:895
Definition: rect.h:34