ccstruct/lmedsq.h

Go to the documentation of this file.
00001 
00020 #ifndef           LMEDSQ_H
00021 #define           LMEDSQ_H
00022 
00023 #include          "points.h"
00024 #include          "varable.h"
00025 #include          "grphics.h"
00026 #include          "notdll.h"
00027 
00033 class LMS
00034 {
00035   public:
00036     LMS(              //constructor
00037         INT32 size);  //no of samples
00038     ~LMS ();                     //destructor
00039     void clear();  //clear samples
00040     void add(                 //add sample
00041              FCOORD sample);  //sample coords
00042     void fit(           //generate fit
00043              float &m,  //output line
00044              float &c);
00045     void constrained_fit(                //fixed gradient
00046                          float fixed_m,  //forced gradient
00047                          float &out_c);  //output line
00048     void fit_quadratic(                          //easy quadratic
00049                        float outlier_threshold,  //min outlier
00050                        double &a,                //x squared
00051                        float &b,                 //x
00052                        float &c);                //constant
00053     void plot(                 //plot fit
00054               WINDOW win,      //window
00055               COLOUR colour);  //colour to draw in
00056     float error() {  //get error
00057       return fitted ? line_error : -1;
00058     }
00059 
00060   private:
00061 
00062     void pick_line(           //random choice
00063                    float &m,  //output line
00064                    float &c);
00065     void pick_quadratic(            //random choice
00066                         double &a,  //output curve
00067                         float &b,
00068                         float &c);
00069     void compute_errors(          //find errors
00070                         float m,  //from line
00071                         float c);
00072                                  //find errors
00073     float compute_quadratic_errors(float outlier_threshold,  //min outlier
00074                                    double a,                 //from curve
00075                                    float m,
00076                                    float c);
00077 
00078     BOOL8 fitted;                //line parts valid
00079     INT32 samplesize;            //max samples
00080     INT32 samplecount;           //current sample size
00081     FCOORD *samples;             //array of samples
00082     float *errors;               //error distances
00083     double a;                    //x squared
00084     float m;                     //line gradient
00085     float c;
00086     float line_error;            //error of fit
00087 };
00088 
00095 extern INT_VAR_H (lms_line_trials, 12, "Number of linew fits to do");
00098 #endif

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1