mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
imageXCorrDiscrete_test.cpp
Go to the documentation of this file.
1/** \file imageXCorrDiscrete_test.cpp
2 */
3#include "../../catch2/catch.hpp"
4
5#include <vector>
6#include <Eigen/Dense>
7
8#define MX_NO_ERROR_REPORTS
9
10#include "../../../include/math/func/gaussian.hpp"
11#include "../../../include/improc/imageXCorrDiscrete.hpp"
12#include "../../../include/improc/eigenCube.hpp"
13
14/** Scenario: centroiding Gaussians with center of light
15 *
16 * Verify center of light calculation
17 *
18 * \anchor tests_improc_imageUtils_imageXCorrDiscrete
19 */
20SCENARIO( "Verify X-Corr with center of light calculation", "[improc::imageXCorrDiscrete]" )
21{
22 GIVEN( "two Gaussians" )
23 {
24 WHEN( "1 at geometric center" )
25 {
27 im0.resize( 64, 64 );
28 im2.resize( 64, 64 );
29
30 mx::math::func::gaussian2D<double>( im0.data(), im0.rows(), im0.cols(), 0., 1.0, 31.5, 31.5, 2 );
31 mx::math::func::gaussian2D<double>( im2.data(), im2.rows(), im2.cols(), 0., 1.0, 31.5 + 4, 31.5 + 4, 2 );
32
33 double x, y;
35
36 mx::improc::eigenImage<double> refIm = im0.block( 10, 10, im0.rows() - 11, im0.cols() - 11 );
37 xcf.refIm( refIm );
38 xcf.m_peakMethod = mx::improc::xcorrPeakMethod::centroid;
39
40 xcf( x, y, im2 );
41
42 std::cerr << x << " " << y << "\n";
43
44 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( 2, 1e-8 ) );
45 REQUIRE_THAT( y, Catch::Matchers::WithinAbs( 2, 1e-8 ) );
46 }
47 WHEN( "geometric quarter" )
48 {
50 im.resize( 64, 64 );
51
52 mx::math::func::gaussian2D<double>( im.data(), im.rows(), im.cols(), 0., 1.0, 15.5, 15.5, 2 );
53
54 double x, y;
56
57 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( 15.5, 1e-8 ) );
58 REQUIRE_THAT( y, Catch::Matchers::WithinAbs( 15.5, 1e-8 ) );
59 }
60 }
61}
Find the optimum shift to align two images using the discrete cross correlation.
int refIm(const ccImT &im0)
Set the reference image.
int imageCenterOfLight(typename imageT::Scalar &x, typename imageT::Scalar &y, const imageT &im)
Calculate the center of light of an image.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
SCENARIO("Verify X-Corr with center of light calculation", "[improc::imageXCorrDiscrete]")