Engauge Digitizer  2
GridClassifier.h
1 #ifndef GRID_CLASSIFIER_H
2 #define GRID_CLASSIFIER_H
3 
4 #include "ColorFilterHistogram.h"
5 
6 class QPixmap;
7 class Transformation;
8 
21 {
22 public:
25 
27  void classify (bool isGnuplot,
28  const QPixmap &originalPixmap,
29  const Transformation &transformation,
30  int &countX,
31  double &startX,
32  double &stepX,
33  int &countY,
34  double &startY,
35  double &stepY);
36 
37 private:
38 
39  // Number of histogram bins could be so large that each bin corresponds to one pixel, but computation time may then be
40  // too slow when doing the correleations later on
41  static int NUM_PIXELS_PER_HISTOGRAM_BINS;
42 
43  static int MIN_STEP_PIXELS;
44  static double PEAK_HALF_WIDTH;
45 
46  int binFromCoordinate (double coord,
47  double coordMin,
48  double coordMax) const; // Inverse of coordinateFromBin
49  void classify();
50  void computeGraphCoordinateLimits (const QImage &image,
51  const Transformation &transformation,
52  double &xMin,
53  double &xMax,
54  double &yMin,
55  double &yMax);
56  double coordinateFromBin (int bin,
57  double coordMin,
58  double coordMax) const; // Inverse of binFromCoordinate
59  void dumpGnuplotCoordinate (const QString &filename,
60  const double *bins,
61  double coordinateMin,
62  double coordinateMax,
63  int binStart,
64  int binStep) const;
65  void initializeHistogramBins ();
66  void loadPicketFence (double picketFence [],
67  int binStart,
68  int binStep,
69  int count,
70  bool isCount) const;
71  void populateHistogramBins (const QImage &image,
72  const Transformation &transformation,
73  double xMin,
74  double xMax,
75  double yMin,
76  double yMax);
77  void searchCountSpace (double bins [],
78  double binStart,
79  double binStep,
80  int &countMax);
81  void searchStartStepSpace (bool isGnuplot,
82  double xMin,
83  double xMax,
84  double yMin,
85  double yMax,
86  double &startX,
87  double &stepX,
88  double &startY,
89  double &stepY,
90  double &binStartX,
91  double &binStepX,
92  double &binStartY,
93  double &binStepY);
94 
95  double *m_binsX;
96  double *m_binsY;
97 
98  int m_numHistogramBins; // More bins improve accuracy but slow computation. Controlled by NUM_PIXELS_PER_HISTOGRAM_BINS
99 };
100 
101 #endif // GRID_CLASSIFIER_H
Affine transformation between screen and graph coordinates, based on digitized axis points...
GridClassifier()
Single constructor.
Classify the grid pattern in an original image.
void classify(bool isGnuplot, const QPixmap &originalPixmap, const Transformation &transformation, int &countX, double &startX, double &stepX, int &countY, double &startY, double &stepY)
Classify the specified image, and return the most probably x and y grid settings. ...