Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Point
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
18
class
DocumentModelPointMatch
;
19
class
QImage;
20
class
QPixmap;
21
22
typedef
QList<PointMatchTriplet>
PointMatchList
;
23
26
class
PointMatchAlgorithm
27
{
28
public
:
30
PointMatchAlgorithm
(
bool
isGnuplot);
31
33
QList<QPoint>
findPoints
(
const
QList<PointMatchPixel> &samplePointPixels,
34
const
QImage &imageProcessed,
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,
42
fftw_complex** arrayPrime,
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,
50
PointMatchList
& listCreated,
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,
56
fftw_complex* samplePrime,
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,
66
fftw_complex* matrix);
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,
77
const
Points
&pointsExisting,
78
int
width,
79
int
height,
80
double
** image,
81
fftw_complex** imagePrime);
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,
88
fftw_complex** samplePrime,
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,
97
fftw_complex* in1,
98
fftw_complex* in2,
99
fftw_complex* out);
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,
135
int
sampleMaskHeight,
136
int
sampleXCenter,
137
int
sampleYCenter,
138
const
DocumentModelPointMatch
&modelPointMatch,
139
int
* imageArray,
140
int
imageWidth,
141
int
imageHeight,
142
PointMatchList
* pointsCreated);
143
144
bool
m_isGnuplot;
145
};
146
147
#endif
// POINT_MATCH_ALGORITHM_H
PointMatchList
QList< PointMatchTriplet > PointMatchList
Definition
PointMatchAlgorithm.h:22
PointMatchPixel.h
PointMatchTriplet.h
Point.h
Points.h
Points
QList< Point > Points
Definition
Points.h:13
DocumentModelPointMatch
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Definition
DocumentModelPointMatch.h:18
PointMatchAlgorithm::findPoints
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.
Definition
PointMatchAlgorithm.cpp:219
PointMatchAlgorithm::PointMatchAlgorithm
PointMatchAlgorithm(bool isGnuplot)
Single constructor.
Definition
PointMatchAlgorithm.cpp:28
Generated on
for Engauge Digitizer by
1.17.0