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

Algorithm returning a list of points that match the specified point. More...

#include <PointMatchAlgorithm.h>

Collaboration diagram for PointMatchAlgorithm:
Collaboration graph

Public Member Functions

 PointMatchAlgorithm (bool isGnuplot)
 Single constructor.
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.

Detailed Description

Algorithm returning a list of points that match the specified point.

This returns a list of matches, from best to worst. This is executed in a separate QThread so the gui thread is not blocked

Definition at line 26 of file PointMatchAlgorithm.h.

Constructor & Destructor Documentation

◆ PointMatchAlgorithm()

PointMatchAlgorithm::PointMatchAlgorithm ( bool isGnuplot)

Single constructor.

Definition at line 28 of file PointMatchAlgorithm.cpp.

28 :
29 m_isGnuplot (isGnuplot)
30{
31 LOG4CPP_INFO_S ((*mainCat)) << "PointMatchAlgorithm::PointMatchAlgorithm";
32}
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

Member Function Documentation

◆ findPoints()

QList< QPoint > PointMatchAlgorithm::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 at line 219 of file PointMatchAlgorithm.cpp.

223{
224 LOG4CPP_INFO_S ((*mainCat)) << "PointMatchAlgorithm::findPoints"
225 << " samplePointPixels=" << samplePointPixels.count();
226
227 // Use larger arrays for computations, if necessary, to improve fft performance
228 int originalWidth = imageProcessed.width();
229 int originalHeight = imageProcessed.height();
230 int width = optimizeLengthForFft(originalWidth);
231 int height = optimizeLengthForFft(originalHeight);
232
233 // The untransformed (unprimed) and transformed (primed) storage arrays can be huge for big pictures, so minimize
234 // the number of allocated arrays at every point in time
235 double *image, *sample, *convolution;
236 fftw_complex *imagePrime, *samplePrime;
237
238 // Compute convolution=F(-1){F(image)*F(*)(sample)}
239 int sampleXCenter, sampleYCenter, sampleXExtent, sampleYExtent;
240 loadImage(imageProcessed,
241 modelPointMatch,
242 pointsExisting,
243 width,
244 height,
245 &image,
246 &imagePrime);
247 loadSample(samplePointPixels,
248 width,
249 height,
250 &sample,
251 &samplePrime,
252 &sampleXCenter,
253 &sampleYCenter,
254 &sampleXExtent,
255 &sampleYExtent);
256 computeConvolution(imagePrime,
257 samplePrime,
258 width,
259 height,
260 &convolution,
261 sampleXCenter,
262 sampleYCenter);
263
264 if (m_isGnuplot) {
265
266 dumpToGnuplot(image,
267 width,
268 height,
269 "image.gnuplot");
270 dumpToGnuplot(sample,
271 width,
272 height,
273 "sample.gnuplot");
274 dumpToGnuplot(convolution,
275 width,
276 height,
277 "convolution.gnuplot");
278 }
279
280 // Assemble local maxima, where each is the maxima centered in a region
281 // having a width of sampleWidth and a height of sampleHeight
282 PointMatchList listCreated;
283 assembleLocalMaxima(convolution,
284 listCreated,
285 width,
286 height);
287 std::sort (listCreated.begin(),
288 listCreated.end());
289
290 // Copy sorted match points to output
291 QList<QPoint> pointsCreated;
292 PointMatchList::iterator itr;
293 for (itr = listCreated.begin(); itr != listCreated.end(); itr++) {
294
295 PointMatchTriplet triplet = *itr;
296 pointsCreated.push_back (triplet.point ());
297
298 // Current order of maxima would be fine if they never overlapped. However, they often overlap so as each
299 // point is pulled off the list, and its pixels are removed from the image, we might consider updating all
300 // succeeding maxima here if those maximax overlap the just-removed maxima. The maxima list is kept
301 // in descending order according to correlation value
302 }
303
304 releaseImageArray(image);
305 releasePhaseArray(imagePrime);
306 releaseImageArray(sample);
307 releasePhaseArray(samplePrime);
308 releaseImageArray(convolution);
309
310 return pointsCreated;
311}
QList< PointMatchTriplet > PointMatchList
QPoint point() const
Return (x,y) coordinates as a point.

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