00001
00002
00003
00004
00005
00006
00007 #ifndef POINT_MATCH_ALGORITHM_H
00008 #define POINT_MATCH_ALGORITHM_H
00009
00010 #include "fftw3.h"
00011 #include "Point.h"
00012 #include "PointMatchPixel.h"
00013 #include "PointMatchTriplet.h"
00014 #include "Points.h"
00015 #include <QList>
00016 #include <QPoint>
00017
00018 class DocumentModelPointMatch;
00019 class QImage;
00020 class QPixmap;
00021
00022 typedef QList<PointMatchTriplet> PointMatchList;
00023
00026 class PointMatchAlgorithm
00027 {
00028 public:
00030 PointMatchAlgorithm(bool isGnuplot);
00031
00033 QList<QPoint> findPoints (const QList<PointMatchPixel> &samplePointPixels,
00034 const QImage &imageProcessed,
00035 const DocumentModelPointMatch &modelPointMatch,
00036 const Points &pointsExisting);
00037
00038 private:
00039
00040
00041 void allocateMemory(double** array,
00042 fftw_complex** arrayPrime,
00043 int width,
00044 int height);
00045
00046
00047
00048
00049 void assembleLocalMaxima(double* convolution,
00050 PointMatchList& listCreated,
00051 int width,
00052 int height);
00053
00054
00055 void computeConvolution(fftw_complex* imagePrime,
00056 fftw_complex* samplePrime,
00057 int width,
00058 int height,
00059 double** convolution,
00060 int sampleXCenter,
00061 int sampleYCenter);
00062
00063
00064 void conjugateMatrix(int width,
00065 int height,
00066 fftw_complex* matrix);
00067
00068
00069 void dumpToGnuplot (double* convolution,
00070 int width,
00071 int height,
00072 const QString &filename) const;
00073
00074
00075 void loadImage(const QImage &imageProcessed,
00076 const DocumentModelPointMatch &modelPointMatch,
00077 const Points &pointsExisting,
00078 int width,
00079 int height,
00080 double** image,
00081 fftw_complex** imagePrime);
00082
00083
00084 void loadSample(const QList<PointMatchPixel> &samplePointPixels,
00085 int width,
00086 int height,
00087 double** sample,
00088 fftw_complex** samplePrime,
00089 int* sampleXCenter,
00090 int* sampleYCenter,
00091 int* sampleXExtent,
00092 int* sampleYExtent);
00093
00094
00095 void multiplyMatrices(int width,
00096 int height,
00097 fftw_complex* in1,
00098 fftw_complex* in2,
00099 fftw_complex* out);
00100
00101
00102
00103
00104 int optimizeLengthForFft(int originalLength);
00105
00106
00107 void populateImageArray(const QImage &imageProcessed,
00108 int width, int height,
00109 double** image);
00110
00111
00112 void populateSampleArray(const QList<PointMatchPixel> &samplePointPixels,
00113 int width,
00114 int height,
00115 double** sample,
00116 int* sampleXCenter,
00117 int* sampleYCenter,
00118 int* sampleXExtent,
00119 int* sampleYExtent);
00120
00121
00122 void releaseImageArray(double* array);
00123 void releasePhaseArray(fftw_complex* array);
00124
00125
00126 void removePixelsNearExistingPoints(double* image,
00127 int imageWidth,
00128 int imageHeight,
00129 const Points &pointsExisting,
00130 int pointSeparation);
00131
00132
00133 void scanImage(bool* sampleMaskArray,
00134 int sampleMaskWidth,
00135 int sampleMaskHeight,
00136 int sampleXCenter,
00137 int sampleYCenter,
00138 const DocumentModelPointMatch &modelPointMatch,
00139 int* imageArray,
00140 int imageWidth,
00141 int imageHeight,
00142 PointMatchList* pointsCreated);
00143
00144 bool m_isGnuplot;
00145 };
00146
00147 #endif // POINT_MATCH_ALGORITHM_H