30TEST_CASE(
"Image cross-correlation with FFT using center of light",
"[improc::imageXCorrFFT]" )
32 GIVEN(
"two Gaussians" )
34 WHEN(
"ref at geometric center, equal even sizes, shift=(+4,+4)" )
42 im0.resize( xsz, ysz );
43 im2.resize( xsz, ysz );
45 double xcen = 0.5 * ( im0.rows() - 1 );
46 double ycen = 0.5 * ( im0.cols() - 1 );
62 xcf.peakMethod( mx::improc::xcorrPeakMethod::centerOfLight );
65 xcf( x, y, peak, im2 );
67 REQUIRE( x == Approx( xshift ) );
68 REQUIRE( y == Approx( yshift ) );
71 WHEN(
"ref at geometric center, equal odd sizes, shift=(+4,+4)" )
79 im0.resize( xsz, ysz );
80 im2.resize( xsz, ysz );
82 double xcen = 0.5 * ( im0.rows() - 1 );
83 double ycen = 0.5 * ( im0.cols() - 1 );
98 xcf.peakMethod( mx::improc::xcorrPeakMethod::centerOfLight );
104 xcf( x, y, peak, im2 );
106 REQUIRE( x == Approx( xshift ) );
107 REQUIRE( y == Approx( yshift ) );
110 WHEN(
"ref at geometric center, equal even sizes, shift=(-3.6,+2.25)" )
112 double xshift = -3.6;
113 double yshift = 2.25;
118 im0.resize( xsz, ysz );
119 im2.resize( xsz, ysz );
121 double xcen = 0.5 * ( im0.rows() - 1 );
122 double ycen = 0.5 * ( im0.cols() - 1 );
136 xcf.peakMethod( mx::improc::xcorrPeakMethod::centerOfLight );
142 xcf( x, y, peak, im2 );
144 REQUIRE( x == Approx( xshift ) );
145 REQUIRE( y == Approx( yshift ) );
148 WHEN(
"ref at geometric center, equal odd sizes, shift=(+1.3,-0.6)" )
151 double yshift = -0.6;
156 im0.resize( xsz, ysz );
157 im2.resize( xsz, ysz );
159 double xcen = 0.5 * ( im0.rows() - 1 );
160 double ycen = 0.5 * ( im0.cols() - 1 );
174 xcf.peakMethod( mx::improc::xcorrPeakMethod::centerOfLight );
180 xcf( x, y, peak, im2 );
182 REQUIRE( x == Approx( xshift ) );
183 REQUIRE( y == Approx( yshift ) );
197TEST_CASE(
"Image cross-correlation with FFT using magnification peak finding",
"[improc::imageXCorrFFT]" )
199 GIVEN(
"two Gaussians" )
201 WHEN(
"ref at geometric center, equal even sizes, shift=(+4,+4)" )
209 im0.resize( xsz, ysz );
210 im2.resize( xsz, ysz );
212 double xcen = 0.5 * ( im0.rows() - 1 );
213 double ycen = 0.5 * ( im0.cols() - 1 );
227 xcf.peakMethod( mx::improc::xcorrPeakMethod::interpPeak );
233 xcf( x, y, peak, im2 );
235 REQUIRE( x == Approx( xshift ) );
236 REQUIRE( y == Approx( yshift ) );
239 WHEN(
"ref at geometric center, equal odd sizes, shift=(+4,+4)" )
247 im0.resize( xsz, ysz );
248 im2.resize( xsz, ysz );
250 double xcen = 0.5 * ( im0.rows() - 1 );
251 double ycen = 0.5 * ( im0.cols() - 1 );
268 xcf.peakMethod( mx::improc::xcorrPeakMethod::interpPeak );
272 xcf( x, y, peak, im2 );
274 REQUIRE( x == Approx( xshift ) );
275 REQUIRE( y == Approx( yshift ) );
278 WHEN(
"ref at geometric center, equal even sizes, shift=(-3.6,+2.3)" )
280 double xshift = -3.6;
286 im0.resize( xsz, ysz );
287 im2.resize( xsz, ysz );
289 double xcen = 0.5 * ( im0.rows() - 1 );
290 double ycen = 0.5 * ( im0.cols() - 1 );
304 xcf.peakMethod( mx::improc::xcorrPeakMethod::interpPeak );
310 xcf( x, y, peak, im2 );
312 REQUIRE( x == Approx( xshift ) );
313 REQUIRE( y == Approx( yshift ) );
316 WHEN(
"ref at geometric center, equal odd sizes, shift=(+1.3,-0.6)" )
319 double yshift = -0.6;
324 im0.resize( xsz, ysz );
325 im2.resize( xsz, ysz );
327 double xcen = 0.5 * ( im0.rows() - 1 );
328 double ycen = 0.5 * ( im0.cols() - 1 );
342 xcf.peakMethod( mx::improc::xcorrPeakMethod::interpPeak );
348 xcf( x, y, peak, im2 );
350 REQUIRE( x == Approx( xshift ) );
351 REQUIRE( y == Approx( yshift ) );
361TEST_CASE(
"Image cross-correlation with FFT using Gaussian peak fit",
"[improc::imageXCorrFFT]" )
363 GIVEN(
"two Gaussians" )
365 WHEN(
"ref at geometric center, equal even sizes, shift=(+4,+4)" )
373 im0.resize( xsz, ysz );
374 im2.resize( xsz, ysz );
376 double xcen = 0.5 * ( im0.rows() - 1 );
377 double ycen = 0.5 * ( im0.cols() - 1 );
393 xcf.peakMethod( mx::improc::xcorrPeakMethod::gaussFit );
396 xcf( x, y, peak, im2 );
398 REQUIRE( x == Approx( xshift ) );
399 REQUIRE( y == Approx( yshift ) );
402 WHEN(
"ref at geometric center, equal odd sizes, shift=(+4,+4)" )
410 im0.resize( xsz, ysz );
411 im2.resize( xsz, ysz );
413 double xcen = 0.5 * ( im0.rows() - 1 );
414 double ycen = 0.5 * ( im0.cols() - 1 );
428 xcf.peakMethod( mx::improc::xcorrPeakMethod::gaussFit );
434 xcf( x, y, peak, im2 );
436 REQUIRE( x == Approx( xshift ) );
437 REQUIRE( y == Approx( yshift ) );
440 WHEN(
"ref at geometric center, equal even sizes, shift=(-3.6,+2.25)" )
442 double xshift = -3.6;
443 double yshift = 2.25;
448 im0.resize( xsz, ysz );
449 im2.resize( xsz, ysz );
451 double xcen = 0.5 * ( im0.rows() - 1 );
452 double ycen = 0.5 * ( im0.cols() - 1 );
468 xcf.peakMethod( mx::improc::xcorrPeakMethod::gaussFit );
472 xcf( x, y, peak, im2 );
474 REQUIRE( x == Approx( xshift ) );
475 REQUIRE( y == Approx( yshift ) );
478 WHEN(
"ref at geometric center, equal odd sizes, shift=(+1.3,-0.6)" )
481 double yshift = -0.6;
486 im0.resize( xsz, ysz );
487 im2.resize( xsz, ysz );
489 double xcen = 0.5 * ( im0.rows() - 1 );
490 double ycen = 0.5 * ( im0.cols() - 1 );
504 xcf.peakMethod( mx::improc::xcorrPeakMethod::gaussFit );
510 xcf( x, y, peak, im2 );
512 REQUIRE( x == Approx( xshift ) );
513 REQUIRE( y == Approx( yshift ) );
realT gaussian2D(const realT x, const realT y, const realT G0, const realT G, const realT x0, const realT y0, const realT sigma)
Find value at position (x,y) of the 2D arbitrarily-centered symmetric Gaussian.