Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
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. More...
 
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. More...
 

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 ( bool  isGnuplot)

Single constructor.

Definition at line 27 of file PointMatchAlgorithm.cpp.

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

Member Function Documentation

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 218 of file PointMatchAlgorithm.cpp.

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

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