mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
signalWindows_test.cpp
Go to the documentation of this file.
1/** \file signalWindows_test.cpp
2 * \brief Tests signal-window generation.
3 */
4#include "../../catch2/catch.hpp"
5
6#include <vector>
7#include <Eigen/Dense>
8
9#define MX_NO_ERROR_REPORTS
10
13
14/** creating 2D Rectangular Tukey Windows
15 *
16 * Verify creation of a 2D rectangular Tukey window
17 *
18 */
19/**
20 * \ingroup signalWindows_unit_tests
21 */
22TEST_CASE( "creating 2D Rectangular Tukey Windows", "[sigproc::signalWindows::tukey2dSquare]" )
23{
24 GIVEN( "a centered square array" )
25 {
26 WHEN( "256x256, alpha=0" )
27 {
28
30 win.resize( 256, 256 );
31
33 win.rows(),
34 win.cols(),
35 256,
36 256,
37 0.0,
38 0.5 * ( win.rows() - 1.0 ),
39 0.5 * ( win.cols() - 1.0 ) );
40
41 REQUIRE( win.sum() == 256 * 256 );
42 }
43
44 WHEN( "256x256, alpha=1" )
45 {
46
48 win.resize( 256, 256 );
49
51 win.rows(),
52 win.cols(),
53 256,
54 256,
55 1.0,
56 0.5 * ( win.rows() - 1.0 ),
57 0.5 * ( win.cols() - 1.0 ) );
58
59 std::vector<float> win1( 256 );
61
62 REQUIRE_THAT( win( 0, 0 ), Catch::Matchers::WithinAbs( win1[0] * win1[0], 1e-6 ) );
63 REQUIRE_THAT( win( 10, 15 ), Catch::Matchers::WithinAbs( win1[10] * win1[15], 1e-6 ) );
64 }
65 WHEN( "256x256, alpha=0.5" )
66 {
67
69 win.resize( 256, 256 );
70
72 win.rows(),
73 win.cols(),
74 256,
75 256,
76 0.5,
77 0.5 * ( win.rows() - 1.0 ),
78 0.5 * ( win.cols() - 1.0 ) );
79
80 std::vector<float> win1( 256 );
82
83 REQUIRE_THAT( win( 0, 0 ), Catch::Matchers::WithinAbs( win1[0] * win1[0], 1e-6 ) );
84 REQUIRE_THAT( win( 10, 15 ), Catch::Matchers::WithinAbs( win1[10] * win1[15], 1e-6 ) );
85 }
86 }
87}
Tools for using the eigen library for image processing.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
TEST_CASE("creating 2D Rectangular Tukey Windows", "[sigproc::signalWindows::tukey2dSquare]")
void tukey(realT *filt, int N, realT alpha)
The Tukey Window.
void tukey2dSquare(realT *filt, int rows, int cols, realT W, realT H, realT alpha, realT xc, realT yc)
Create a 2-D Tukey window on a rectangle.
Procedures to calculate window functions for signal processing.