mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
signalWindows_test.cpp
1/** \file psdFilter_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/sigproc/signalWindows.hpp"
11#include "../../../include/improc/eigenImage.hpp"
12#include "../../../include/improc/milkImage.hpp"
13
14/** Scenario: creating 2D Rectangular Tukey Windows
15 *
16 * Verify creation of a 2D rectangular Tukey window
17 *
18 * \anchor tests_sigproc_signalWindows_Tukey2DSquare
19 */
20SCENARIO( "creating 2D Rectangular Tukey Windows", "[sigproc::signalWindows::tukey2dSquare]" )
21{
22 GIVEN( "a centered square array" )
23 {
24 WHEN( "256x256, alpha=0" )
25 {
26
28 win.resize( 256, 256 );
29
30 mx::sigproc::window::tukey2dSquare<float>( win.data(),
31 win.rows(),
32 win.cols(),
33 256,
34 256,
35 0.0,
36 0.5 * ( win.rows() - 1.0 ),
37 0.5 * ( win.cols() - 1.0 ) );
38
39 REQUIRE( win.sum() == 256 * 256 );
40 }
41
42 WHEN( "256x256, alpha=1" )
43 {
44
46 win.resize( 256, 256 );
47
48 mx::sigproc::window::tukey2dSquare<float>( win.data(),
49 win.rows(),
50 win.cols(),
51 256,
52 256,
53 1.0,
54 0.5 * ( win.rows() - 1.0 ),
55 0.5 * ( win.cols() - 1.0 ) );
56
57 std::vector<float> win1( 256 );
58 mx::sigproc::window::tukey<float>( win1, 1.0 );
59
60 REQUIRE( win( 0, 0 ) == win1[0] * win1[0] );
61 REQUIRE( win( 10, 15 ) == win1[10] * win1[15] );
62 }
63 WHEN( "256x256, alpha=0.5" )
64 {
65
67 win.resize( 256, 256 );
68
69 mx::sigproc::window::tukey2dSquare<float>( win.data(),
70 win.rows(),
71 win.cols(),
72 256,
73 256,
74 0.5,
75 0.5 * ( win.rows() - 1.0 ),
76 0.5 * ( win.cols() - 1.0 ) );
77
78 std::vector<float> win1( 256 );
79 mx::sigproc::window::tukey<float>( win1, 0.5 );
80
82 mwin.create( "win", win );
83
84 REQUIRE( win( 0, 0 ) == win1[0] * win1[0] );
85 REQUIRE( win( 10, 15 ) == win1[10] * win1[15] );
86 }
87 }
88}
Class to interface with an ImageStreamIO image in shared memory.
void create(const std::string &imname, uint32_t sz0, uint32_t sz1)
Create (or re-create) and connect to an image, allocating the eigenMap.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.