36 std::string
const input = argc >= 2 ? argv[1] :
"cameraman256";
37 std::string
const output = argc == 3 ? argv[2] :
"none";
39 std::cout <<
"Usage:\n"
42 <<
" [input [output]]\n\n"
43 "- input: path to the image to clean (or name of standard SOPT image)\n"
44 "- output: filename pattern for output image\n";
48 auto const seed = std::time(
nullptr);
49 std::srand(
static_cast<unsigned int>(seed));
50 std::mt19937
mersenne(std::time(
nullptr));
65 auto const psi = sopt::linear_transform<Scalar>(wavelet, image.rows(), image.cols());
68 Vector const y0 = sampling * Vector::Map(image.data(), image.size());
69 auto constexpr snr = 30.0;
70 auto const sigma = y0.stableNorm() / std::sqrt(y0.size()) * std::pow(10.0, -(snr / 20.0));
71 auto const epsilon = std::sqrt(nmeasure + 2 * std::sqrt(y0.size())) *
sigma;
74 std::normal_distribution<> gaussian_dist(0,
sigma);
78 if (output !=
"none") {
81 "dirty_" + output +
".tiff");
87 .regulariser_strength(1e-1)
88 .relative_variation(5e-4)
89 .l2ball_proximal_epsilon(
epsilon)
91 .l1_proximal_tolerance(1e-2)
93 .l1_proximal_itermax(50)
94 .l1_proximal_positivity_constraint(
true)
95 .l1_proximal_real_constraint(
true)
97 .lagrange_update_scale(0.9)
104 auto const diagnostic = padmm();
110 if (not diagnostic.good)
throw std::runtime_error(
"Did not converge!");
112 SOPT_HIGH_LOG(
"SOPT-proximal-ADMM converged in {} iterations", diagnostic.niters);
113 if (output !=
"none")
An operator that samples a set of measurements.
ImagingProximalADMM< Scalar > & residual_convergence(Real const &tolerance)
Helper function to set-up default residual convergence function.
std::unique_ptr< std::mt19937_64 > mersenne(new std::mt19937_64(0))
#define SOPT_HIGH_LOG(...)
High priority message.
void set_level(const std::string &level)
Method to set the logging level of the default Log object.
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.
Vector< T > dirty(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image, RANDOM &mersenne)
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.
sopt::Vector< Scalar > Vector
sopt::Matrix< Scalar > Matrix
sopt::Image< Scalar > Image