Engauge Digitizer 2
Loading...
Searching...
No Matches
PointMatchAlgorithm.h
Go to the documentation of this file.
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 POINT_MATCH_ALGORITHM_H
8#define POINT_MATCH_ALGORITHM_H
9
10#include "fftw3.h"
11#include "Point.h"
12#include "PointMatchPixel.h"
13#include "PointMatchTriplet.h"
14#include "Points.h"
15#include <QList>
16#include <QPoint>
17
19class QImage;
20class QPixmap;
21
23
27{
28 public:
30 PointMatchAlgorithm(bool isGnuplot);
31
35 const DocumentModelPointMatch &modelPointMatch,
36 const Points &pointsExisting);
37
38 private:
39
40 // Allocate memory for an image array and phase array pair before calculations
41 void allocateMemory(double** array,
43 int width,
44 int height);
45
46 // Find each local maxima that is the largest value in a region that is:
47 // 1. as big as the the sample
48 // 2. centered about that local maxima
49 void assembleLocalMaxima(double* convolution,
51 int width,
52 int height);
53
54 // Compute convolution in image space from phase space image and sample arrays
55 void computeConvolution(fftw_complex* imagePrime,
57 int width,
58 int height,
59 double** convolution,
60 int sampleXCenter,
61 int sampleYCenter);
62
63 // In-place replacement of matrix by its complex conjugate
64 void conjugateMatrix(int width,
65 int height,
67
68 // Dump to file for 3d plotting by gnuplot
69 void dumpToGnuplot (double* convolution,
70 int width,
71 int height,
72 const QString &filename) const;
73
74 // Load image and imagePrime arrays
75 void loadImage(const QImage &imageProcessed,
76 const DocumentModelPointMatch &modelPointMatch,
78 int width,
79 int height,
80 double** image,
82
83 // Load sample and samplePrime arrays, and compute center location and extent
84 void loadSample(const QList<PointMatchPixel> &samplePointPixels,
85 int width,
86 int height,
87 double** sample,
89 int* sampleXCenter,
90 int* sampleYCenter,
91 int* sampleXExtent,
92 int* sampleYExtent);
93
94 // Multiply corresponding elements of two matrices into a third matrix
95 void multiplyMatrices(int width,
96 int height,
100
101 // Given an original array length, this method returns an array length that includes enough padding so that the
102 // array length equals 2^a * 3^b * 5^c * 7^d, which optimizes the fft performance. Typical memory penalties are
103 // less than 6% to get a cpu performance increase of 0% to roughly 100% or 200%
104 int optimizeLengthForFft(int originalLength);
105
106 // Populate image array with processed image
107 void populateImageArray(const QImage &imageProcessed,
108 int width, int height,
109 double** image);
110
111 // Populate sample array with sample image
112 void populateSampleArray(const QList<PointMatchPixel> &samplePointPixels,
113 int width,
114 int height,
115 double** sample,
116 int* sampleXCenter,
117 int* sampleYCenter,
118 int* sampleXExtent,
119 int* sampleYExtent);
120
121 // Release memory for one array after finishing calculations
122 void releaseImageArray(double* array);
123 void releasePhaseArray(fftw_complex* array);
124
125 // Prevent duplication of existing points. this function returns the number of pixels removed
126 void removePixelsNearExistingPoints(double* image,
127 int imageWidth,
128 int imageHeight,
129 const Points &pointsExisting,
130 int pointSeparation);
131
132 // Correlate the sample point with the image, returning points in list that is sorted by correlation
133 void scanImage(bool* sampleMaskArray,
134 int sampleMaskWidth,
136 int sampleXCenter,
137 int sampleYCenter,
138 const DocumentModelPointMatch &modelPointMatch,
139 int* imageArray,
140 int imageWidth,
141 int imageHeight,
143
144 bool m_isGnuplot;
145};
146
147#endif // POINT_MATCH_ALGORITHM_H
const int INNER_RADIUS_MIN
QList< PointMatchTriplet > PointMatchList
QList< Point > Points
Definition Points.h:13
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Algorithm returning a list of points that match the specified point.
QList< QPoint > findPoints(const QList< PointMatchPixel > &samplePointPixels, const QImage &imageProcessed, const DocumentModelPointMatch &modelPointMatch, const Points &pointsExisting)
Find points that match the specified sample point pixels. They are sorted by best-to-worst match.
PointMatchAlgorithm(bool isGnuplot)
Single constructor.