170 typedef std::complex<float> pixelc_t;
177 float mean = img->
mean();
178 pixelc_t* cimg =
new pixelc_t[w*h];
179 std::fill(cimg, cimg+w*h, pixelc_t());
180 for (
int y=0;y<img->
h;y++) {
181 for (
int x=0;x<img->
w;x++) {
182 cimg[y*w+x] = img->
data[y*img->
w+x]-mean;
187 FFT2D(cimg,w,h,
false);
190 pixelc_t* smpimg =
new pixelc_t[w*h];
191 std::fill(smpimg, smpimg+w*h, pixelc_t());
193 for (
int y=0;y<cfg->
roi;y++)
194 for (
int x=0;x<cfg->
roi;x++)
195 smpimg[ ((y-cfg->
roi)&(h-1)) * w + ( (x-cfg->
roi)&(w-1))] = sample[cfg->
roi*y+x]-smpmean;
198 FFT2D(smpimg,w,h,
false);
200 for (
int i=0;i<w*h;i++)
202 FFT2D(cimg,w,h,
true);
205 for (
int i=0;i<w*h;i++)
206 maxVal=std::max(maxVal, cimg[i].real());
208 std::vector<Position> pts;
209 for (
int y=0;y<img->
h;y++) {
210 for (
int x=0;x<img->
w;x++) {
211 if (cimg[y*w+x].real()>maxVal*cfg->
similarity )
TImageData< float > ImageData
void RecenterAndFilter(ImageData *img, std::vector< Position > &pts, Config *cfg)
Position SearchArea(std::complex< float > *cimg, int w, int h, int px, int py, int dist)
void FFT2D(std::complex< float > *d, int w, int h, bool inverse)