8 #include <catch2/catch_all.hpp>
22 #include "tools_for_tests/directories.h"
33 extern std::unique_ptr<std::mt19937_64>
mersenne;
34 std::string
const input =
"cameraman256";
38 sopt::t_uint const nmeasure = std::floor(0.5 * image.size());
44 auto const psi = sopt::linear_transform<Scalar>(wavelet, image.rows(), image.cols());
46 Vector const y0 = sampling * Vector::Map(image.data(), image.size());
47 auto constexpr snr = 30.0;
48 auto const sigma = y0.stableNorm() / std::sqrt(y0.size()) * std::pow(10.0, -(snr / 20.0));
49 auto const epsilon = std::sqrt(nmeasure + 2 * std::sqrt(y0.size())) *
sigma;
51 std::normal_distribution<> gaussian_dist(0,
sigma);
55 Eigen::VectorXd dirty_image = sampling.
adjoint() * y;
57 sopt::t_real const regulariser_strength = (psi.adjoint() * (sampling.
adjoint() * y)).real().maxCoeff() * 1e-2;
64 .regulariser_strength(regulariser_strength)
65 .l2ball_proximal_epsilon(
epsilon)
66 .relative_variation(5e-4)
68 .positivity_constraint(
true);
70 auto const diagnostic = pd();
72 CHECK(diagnostic.good);
73 CHECK(diagnostic.niters < 500);
79 "pd_reconstruction.tiff");
82 Eigen::Map<const Eigen::VectorXd> flat_image(image.data(), image.size());
83 auto mse = (flat_image - diagnostic.x).array().square().sum() / image.size();
An operator that samples a set of measurements.
ImagingPrimalDual &::type Psi(ARGS &&... args)
ImagingPrimalDual< Scalar > & residual_convergence(Real const &tolerance)
Helper function to set-up default residual convergence function.
ImagingPrimalDual &::type Phi(ARGS &&... args)
std::unique_ptr< std::mt19937_64 > mersenne(new std::mt19937_64(0))
#define SOPT_HIGH_LOG(...)
High priority message.
void write_tiff(Image<> const &image, std::string const &filename)
Writes a tiff greyscale file.
Wavelet factory(const std::string &name, t_uint nlevels)
Creates a wavelet transform object.
int t_int
Root of the type hierarchy for signed integers.
double t_real
Root of the type hierarchy for real numbers.
size_t t_uint
Root of the type hierarchy for unsigned integers.
Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic > Image
A 2-dimensional list of elements of given type.
real_type< T >::type epsilon(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
real_type< T >::type sigma(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.
TEST_CASE("Primal Dual Inpainting")
sopt::Vector< Scalar > Vector
sopt::Matrix< Scalar > Matrix
sopt::Image< Scalar > Image