Engauge Digitizer  2
GridClassifier.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef GRID_CLASSIFIER_H
8 #define GRID_CLASSIFIER_H
9 
10 #include "ColorFilterHistogram.h"
11 
12 class QPixmap;
13 class Transformation;
14 
27 {
28 public:
31 
33  void classify (bool isGnuplot,
34  const QPixmap &originalPixmap,
35  const Transformation &transformation,
36  int &countX,
37  double &startX,
38  double &stepX,
39  int &countY,
40  double &startY,
41  double &stepY);
42 
43 private:
44 
45  // Number of histogram bins could be so large that each bin corresponds to one pixel, but computation time may then be
46  // too slow when doing the correleations later on
47  static int NUM_PIXELS_PER_HISTOGRAM_BINS;
48 
49  static int MIN_STEP_PIXELS;
50  static double PEAK_HALF_WIDTH;
51  static int BIN_START_UNSHIFTED;
52 
53  int binFromCoordinate (double coord,
54  double coordMin,
55  double coordMax) const; // Inverse of coordinateFromBin
56  void classify();
57  void computeGraphCoordinateLimits (const QImage &image,
58  const Transformation &transformation,
59  double &xMin,
60  double &xMax,
61  double &yMin,
62  double &yMax);
63  double coordinateFromBin (int bin,
64  double coordMin,
65  double coordMax) const; // Inverse of binFromCoordinate
66  void copyVectorToVector (const double from [],
67  double to []) const;
68  void dumpGnuplotCoordinate (const QString &coordinateLabel,
69  double corr,
70  const double *bins,
71  double coordinateMin,
72  double coordinateMax,
73  int binStart,
74  int binStep) const;
75  void dumpGnuplotCorrelations (const QString &coordinateLabel,
76  double valueMin,
77  double valueMax,
78  const double signalA [],
79  const double signalB [],
80  const double correlationsMax []);
81  void initializeHistogramBins ();
82  void loadPicketFence (double picketFence [],
83  int binStart,
84  int binStep,
85  int count,
86  bool isCount) const;
87  void populateHistogramBins (const QImage &image,
88  const Transformation &transformation,
89  double xMin,
90  double xMax,
91  double yMin,
92  double yMax);
93  void searchCountSpace (double bins [],
94  double binStart,
95  double binStep,
96  int &countMax);
97  void searchStartStepSpace (bool isGnuplot,
98  double bins [],
99  const QString &coordinateLabel,
100  double valueMin,
101  double valueMax,
102  double &start,
103  double &step,
104  double &binStart,
105  double &binStep);
106 
107  double *m_binsX;
108  double *m_binsY;
109 
110  int m_numHistogramBins; // More bins improve accuracy but slow computation. Controlled by NUM_PIXELS_PER_HISTOGRAM_BINS
111 };
112 
113 #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. ...