Engauge Digitizer 2
Loading...
Searching...
No Matches
GridClassifier Class Reference

Classify the grid pattern in an original image. More...

#include <GridClassifier.h>

Collaboration diagram for GridClassifier:
Collaboration graph

Public Member Functions

 GridClassifier ()
 Single constructor.
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.

Detailed Description

Classify the grid pattern in an original image.

This class uses the following tricks for faster performance:

  1. FFT is used for "fast correlations" in frequency space rather than graph space
  2. FFT initialization/shutdown housekeeping is done once
  3. Rather than a combinatorial search of grid line start, step and count, we exploit the periodicity of the FFT to search start and step as the first step, and then as a separate second step we search count. In the first step, the periodicity means the repeating grid lines wrap around the end of the end of the image back around to the start of the image - so the grid line count is not even relevant. In other words, the searches are START X STEP + COUNT rather than START X STEP X COUNT

Definition at line 26 of file GridClassifier.h.

Constructor & Destructor Documentation

◆ GridClassifier()

GridClassifier::GridClassifier ( )

Single constructor.

Definition at line 33 of file GridClassifier.cpp.

34{
35}

Member Function Documentation

◆ classify()

void GridClassifier::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.

Definition at line 50 of file GridClassifier.cpp.

59{
60 LOG4CPP_INFO_S ((*mainCat)) << "GridClassifier::classify";
61
62 QImage image = originalPixmap.toImage ();
63
64 m_numHistogramBins = image.width() / NUM_PIXELS_PER_HISTOGRAM_BINS;
65 ENGAUGE_ASSERT (m_numHistogramBins > 1);
66
67 double xMin, xMax, yMin, yMax;
68 double binStartX, binStepX, binStartY, binStepY;
69
70 m_binsX = new double [unsigned (m_numHistogramBins)];
71 m_binsY = new double [unsigned (m_numHistogramBins)];
72
73 computeGraphCoordinateLimits (image,
74 transformation,
75 xMin,
76 xMax,
77 yMin,
78 yMax);
79 initializeHistogramBins ();
80 populateHistogramBins (image,
81 transformation,
82 xMin,
83 xMax,
84 yMin,
85 yMax);
86 searchStartStepSpace (isGnuplot,
87 m_binsX,
88 "x",
89 xMin,
90 xMax,
91 startX,
92 stepX,
93 binStartX,
94 binStepX);
95 searchStartStepSpace (isGnuplot,
96 m_binsY,
97 "y",
98 yMin,
99 yMax,
100 startY,
101 stepY,
102 binStartY,
103 binStepY);
104 searchCountSpace (m_binsX,
105 binStartX,
106 binStepX,
107 countX);
108 searchCountSpace (m_binsY,
109 binStartY,
110 binStepY,
111 countY);
112
113 delete [] m_binsX;
114 delete [] m_binsY;
115}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

The documentation for this class was generated from the following files: