4#include "../../catch2/catch.hpp"
11#define MX_NO_ERROR_REPORTS
22TEST_CASE(
"Image invalid-pixel detection handles sentinel and nonfinite values",
"[improc::isInvalidPixel]" )
32#ifdef MXLIB_INVALID_NUMBER_VALUE
49TEST_CASE(
"Verify center of light calculation",
"[improc::imageCenterOfLight]" )
53 WHEN(
"geometric center" )
63 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( 31.5, 1e-8 ) );
64 REQUIRE_THAT( y, Catch::Matchers::WithinAbs( 31.5, 1e-8 ) );
66 WHEN(
"geometric quarter" )
76 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( 15.5, 1e-8 ) );
77 REQUIRE_THAT( y, Catch::Matchers::WithinAbs( 15.5, 1e-8 ) );
86TEST_CASE(
"imageMedian selects valid image samples",
"[improc::imageMedian]" )
89 image << 1.0, 9.0, 3.0, 7.0, 5.0, 11.0;
93 std::vector<double> work;
95 REQUIRE( work.size() ==
static_cast<size_t>( image.size() ) );
97 Eigen::Array<int, Eigen::Dynamic, Eigen::Dynamic> mask( 2, 3 );
98 mask << 1, 0, 0, 0, 1, 1;
101 REQUIRE( work.size() == 3 );
110TEST_CASE(
"zeroNaNCube replaces invalid pixels and reports a mask",
"[improc::zeroNaNCube]" )
113 cube.
cube().setOnes();
114 cube.
image( 0 )( 0, 1 ) = std::numeric_limits<float>::quiet_NaN();
115 cube.
image( 1 )( 1, 2 ) = std::numeric_limits<float>::infinity();
120 REQUIRE( cube.
image( 0 )( 0, 1 ) == 0.0F );
121 REQUIRE( cube.
image( 1 )( 1, 2 ) == 0.0F );
122 REQUIRE( cube.
image( 0 )( 1, 1 ) == 1.0F );
123 REQUIRE( mask.rows() == cube.rows() );
124 REQUIRE( mask.cols() == cube.cols() );
125 REQUIRE( mask.planes() == cube.planes() );
126 REQUIRE( mask.
image( 0 )( 0, 1 ) == 1.0F );
127 REQUIRE( mask.
image( 1 )( 1, 2 ) == 1.0F );
128 REQUIRE( mask.
image( 0 )( 1, 1 ) == 0.0F );
131 REQUIRE( cube.
image( 0 )( 1, 1 ) == 1.0F );
An image cube with an Eigen-like API.
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > cube()
Returns a 2D Eigen::Eigen::Map pointed at the entire cube.
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image(Index n)
Returns a 2D Eigen::Eigen::Map pointed at the specified image.
An image cube with an Eigen API.
Declarations for utilities related to the Gaussian function.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
imageT::Scalar imageMedian(const imageT &mat, const maskT *mask, std::vector< typename imageT::Scalar > *work=0)
Calculate the median of an Eigen-like array.
int imageCenterOfLight(typename imageT::Scalar &x, typename imageT::Scalar &y, const imageT &im)
Calculate the center of light of an image.
void zeroNaNCube(cubeT &imc, maskCubeT *mask)
Zero any NaNs in an image cube.
realT gaussian2D(const realT x, const realT y, const realT G0, const realT G, const realT x0, const realT y0, const realT sigma)
Find value at position (x,y) of the 2D arbitrarily-centered symmetric Gaussian.
bool isNan(realT value)
Test whether a floating-point value is NaN, including under finite-math-only optimization.
TEST_CASE("Image invalid-pixel detection handles sentinel and nonfinite values", "[improc::isInvalidPixel]")
Verify image invalid-pixel generation and classification for floating-point values.
constexpr realT invalidNumber()
Return the configured invalid image-pixel value.
bool isInvalidPixel(realT value)
Check whether a value represents an invalid image pixel.
Header for the image processing utilities.