mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
imageUtils_test.cpp
Go to the documentation of this file.
1 /** \file imageUtils_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/imageUtils.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_imageCenterOfLight
19  */
20 SCENARIO( "Verify center of light calculation", "[improc::imageCenterOfLight]" )
21 {
22  GIVEN("a Gaussian")
23  {
24  WHEN("geometric center")
25  {
27  im.resize(64,64);
28 
29  mx::math::func::gaussian2D<double>(im.data(), im.rows(), im.cols(), 0., 1.0, 31.5, 31.5, 2);
30 
31  double x, y;
33 
34  REQUIRE(fabs(x-31.5) < 1e-8 );
35  REQUIRE(fabs(y-31.5) < 1e-8 );
36  }
37  WHEN("geometric quarter")
38  {
40  im.resize(64,64);
41 
42  mx::math::func::gaussian2D<double>(im.data(), im.rows(), im.cols(), 0., 1.0, 15.5, 15.5, 2);
43 
44  double x, y;
46 
47  REQUIRE(fabs(x-15.5) < 1e-8 );
48  REQUIRE(fabs(y-15.5) < 1e-8 );
49  }
50  }
51 }
52 
53 
54 
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
Definition: eigenImage.hpp:44
int imageCenterOfLight(typename imageT::Scalar &x, typename imageT::Scalar &y, const imageT &im)
Calculate the center of light of an image.
Definition: imageUtils.hpp:163
SCENARIO("Verify center of light calculation", "[improc::imageCenterOfLight]")