mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
imageMasks_test.cpp
Go to the documentation of this file.
1/** \file imageMasks_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/improc/imageMasks.hpp"
11#include "../../../include/improc/eigenImage.hpp"
12
13/** Scenario: Masking wedges in an image
14 *
15 * Verify wedge masking, including that all pixels are masked for continuous rotations of the wedge
16 *
17 * \anchor tests_improc_imageMasks_maskWedge
18 */
19SCENARIO( "Masking wedges in an image", "[improc::imageMasks::maskWedge]" )
20{
21 GIVEN( "a single wedge" )
22 {
23 WHEN( "geometric center, 0-90 degrees" )
24 {
26 im.resize( 1024, 1024 );
27 im.setZero();
28
29 double xcen = 0.5 * ( im.rows() - 1 );
30 double ycen = 0.5 * ( im.cols() - 1 );
31
32 mx::improc::maskWedge( im, xcen, ycen, 45.0, 45.0, 1 );
33
34 REQUIRE( im.sum() == 512 * 512 );
35 }
36 WHEN( "geometric center, 90-180 degrees" )
37 {
39 im.resize( 1024, 1024 );
40 im.setZero();
41
42 double xcen = 0.5 * ( im.rows() - 1 );
43 double ycen = 0.5 * ( im.cols() - 1 );
44
45 mx::improc::maskWedge( im, xcen, ycen, 135.0, 45.0, 1 );
46
47 REQUIRE( im.sum() == 512 * 512 );
48 }
49 WHEN( "geometric center, 180-270 degrees" )
50 {
52 im.resize( 1024, 1024 );
53 im.setZero();
54
55 double xcen = 0.5 * ( im.rows() - 1 );
56 double ycen = 0.5 * ( im.cols() - 1 );
57
58 mx::improc::maskWedge( im, xcen, ycen, 225.0, 45.0, 1 );
59
60 REQUIRE( im.sum() == 512 * 512 );
61 }
62 WHEN( "geometric center, 270-360 degrees" )
63 {
65 im.resize( 1024, 1024 );
66 im.setZero();
67
68 double xcen = 0.5 * ( im.rows() - 1 );
69 double ycen = 0.5 * ( im.cols() - 1 );
70
71 mx::improc::maskWedge( im, xcen, ycen, 315.0, 45.0, 1 );
72
73 REQUIRE( im.sum() == 512 * 512 );
74 }
75 WHEN( "geometric center, 45-135 degrees" )
76 {
78 im.resize( 1024, 1024 );
79 im.setZero();
80
81 double xcen = 0.5 * ( im.rows() - 1 );
82 double ycen = 0.5 * ( im.cols() - 1 );
83
84 mx::improc::maskWedge( im, xcen, ycen, 90.0, 45.0, 1 );
85
86 REQUIRE( im.sum() == 512 * 512 );
87 }
88 WHEN( "geometric center, 135-225 degrees" )
89 {
91 im.resize( 1024, 1024 );
92 im.setZero();
93
94 double xcen = 0.5 * ( im.rows() - 1 );
95 double ycen = 0.5 * ( im.cols() - 1 );
96
97 mx::improc::maskWedge( im, xcen, ycen, 180.0, 45.0, 1 );
98
99 REQUIRE( im.sum() == 512 * 512 );
100 }
101 WHEN( "geometric center, 225-315 degrees" )
102 {
104 im.resize( 1024, 1024 );
105 im.setZero();
106
107 double xcen = 0.5 * ( im.rows() - 1 );
108 double ycen = 0.5 * ( im.cols() - 1 );
109
110 mx::improc::maskWedge( im, xcen, ycen, 270.0, 45.0, 1 );
111
112 REQUIRE( im.sum() == 512 * 512 );
113 }
114 WHEN( "geometric center, 315-45 degrees" )
115 {
117 im.resize( 1024, 1024 );
118 im.setZero();
119
120 double xcen = 0.5 * ( im.rows() - 1 );
121 double ycen = 0.5 * ( im.cols() - 1 );
122
123 mx::improc::maskWedge( im, xcen, ycen, 0.0, 45.0, 1 );
124
125 REQUIRE( im.sum() == 512 * 512 );
126 }
127 WHEN( "geometric center, 3 wedges of 120 degrees" )
128 {
130 im60.resize( 1024, 1024 );
131 im60.setZero();
132
133 double xcen = 0.5 * ( im60.rows() - 1 );
134 double ycen = 0.5 * ( im60.cols() - 1 );
135
136 mx::improc::maskWedge( im60, xcen, ycen, 60.0, 60.0, 1 );
137
139 im180.resize( 1024, 1024 );
140 im180.setZero();
141
142 xcen = 0.5 * ( im180.rows() - 1 );
143 ycen = 0.5 * ( im180.cols() - 1 );
144
145 mx::improc::maskWedge( im180, xcen, ycen, 180.0, 60.0, 1 );
146
148 im300.resize( 1024, 1024 );
149 im300.setZero();
150
151 xcen = 0.5 * ( im300.rows() - 1 );
152 ycen = 0.5 * ( im300.cols() - 1 );
153
154 mx::improc::maskWedge( im300, xcen, ycen, 300.0, 60.0, 1 );
155
156 REQUIRE( im60.sum() + im180.sum() + im300.sum() == 1024 * 1024 );
157 }
158 }
159}
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
void maskWedge(arrayT &m, typename arrayT::Scalar xcen, typename arrayT::Scalar ycen, typename arrayT::Scalar angCen, typename arrayT::Scalar angHW, typename arrayT::Scalar val=0)
Mask a wedge in an image.
SCENARIO("Masking wedges in an image", "[improc::imageMasks::maskWedge]")