tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccstruct/quspline.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        quspline.h  (Formerly qspline.h)
00003  * Description: Code for the QSPLINE class.
00004  * Author:              Ray Smith
00005  * Created:             Tue Oct 08 17:16:12 BST 1991
00006  *
00007  * (C) Copyright 1991, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef           QUSPLINE_H
00021 #define           QUSPLINE_H
00022 
00023 #include          "quadratc.h"
00024 #include          "serialis.h"
00025 #include          "memry.h"
00026 #include          "rect.h"
00027 
00028 class ROW;
00029 struct Pix;
00030 
00031 class QSPLINE
00032 {
00033   friend void make_first_baseline(TBOX *,
00034                                   int,
00035                                   int *,
00036                                   int *,
00037                                   QSPLINE *,
00038                                   QSPLINE *,
00039                                   float);
00040   friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float);
00041   friend void tweak_row_baseline(ROW *, double, double);
00042   public:
00043     QSPLINE() {  //empty constructor
00044       segments = 0;
00045       xcoords = NULL;            //everything empty
00046       quadratics = NULL;
00047     }
00048     QSPLINE(  //copy constructor
00049             const QSPLINE &src);
00050     QSPLINE(                  //constructor
00051             inT32 count,      //number of segments
00052             inT32 *xstarts,   //segment starts
00053             double *coeffs);  //coefficients
00054     ~QSPLINE ();                 //destructor
00055     QSPLINE (                    //least squares fit
00056       int xstarts[],             //spline boundaries
00057       int segcount,              //no of segments
00058       int xcoords[],             //points to fit
00059       int ycoords[], int blobcount,//no of coords
00060       int degree);               //function
00061 
00062     double step(            //step change
00063                 double x1,  //between coords
00064                 double x2);
00065     double y(                  //evaluate
00066              double x) const;  //at x
00067 
00068     void move(              // reposition spline
00069               ICOORD vec);  // by vector
00070     BOOL8 overlap(                   //test overlap
00071                   QSPLINE *spline2,  //2 cannot be smaller
00072                   double fraction);  //by more than this
00073     void extrapolate(                  //linear extrapolation
00074                      double gradient,  //gradient to use
00075                      int left,         //new left edge
00076                      int right);       //new right edge
00077 
00078 #ifndef GRAPHICS_DISABLED
00079     void plot(                       //draw it
00080               ScrollView* window,         //in window
00081               ScrollView::Color colour) const;  //in colour
00082 #endif
00083 
00084     // Paint the baseline over pix. If pix has depth of 32, then the line will
00085     // be painted in red. Otherwise it will be painted in black.
00086     void plot(Pix* pix) const;
00087 
00088     QSPLINE & operator= (
00089       const QSPLINE & source);   //from this
00090 
00091   private:
00092 
00093     inT32 spline_index(                  //binary search
00094                        double x) const;  //for x
00095     inT32 segments;              //no of segments
00096     inT32 *xcoords;              //no of coords
00097     QUAD_COEFFS *quadratics;     //spline pieces
00098 };
00099 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines