38   std::string 
const input = argc >= 2 ? argv[1] : 
"cameraman256";
 
   39   std::string 
const output = argc == 3 ? argv[2] : 
"none";
 
   41     std::cout << 
"Usage:\n" 
   44               << 
" [input [output]]\n\n" 
   45                  "- input: path to the image to clean (or name of standard SOPT image)\n" 
   46                  "- output: filename pattern for output image\n";
 
   50   auto const seed = std::time(
nullptr);
 
   51   std::srand(
static_cast<unsigned int>(seed));
 
   52   std::mt19937 
mersenne(std::time(
nullptr));
 
   58   SOPT_HIGH_LOG(
"Image size: {} x {} = {}", image.cols(), image.rows(), image.size());
 
   61   sopt::t_uint const nmeasure = std::floor(0.5 * image.size());
 
   70   auto const psi = sopt::linear_transform<Scalar>(wavelet, image.rows(), image.cols());
 
   71   SOPT_LOW_LOG(
"Wavelet coefficients: {}", (psi.adjoint() * image).size());
 
   74   Vector const y0 = sampling * Vector::Map(image.data(), image.size());
 
   75   auto constexpr snr = 30.0;
 
   76   auto const sigma = y0.stableNorm() / std::sqrt(y0.size()) * std::pow(10.0, -(snr / 20.0));
 
   77   auto const epsilon = std::sqrt(nmeasure + 2 * std::sqrt(y0.size())) * 
sigma;
 
   80   std::normal_distribution<> gaussian_dist(0, 
sigma);
 
   84   if (output != 
"none") {
 
   87                                 "dirty_" + output + 
".tiff");
 
   93   auto fb = std::make_shared<sopt::algorithm::ImagingForwardBackward<Scalar>>(y);
 
   97     .regulariser_strength(regulariser_strength)  
 
   98     .relative_variation(1e-3)
 
   99     .residual_tolerance(0)
 
  105   auto gp = std::make_shared<sopt::algorithm::L1GProximal<Scalar>>(
false);
 
  106   gp->l1_proximal_tolerance(1e-4)
 
  108     .l1_proximal_itermax(50)
 
  109     .l1_proximal_positivity_constraint(
true)
 
  110     .l1_proximal_real_constraint(
true)
 
  120   const sopt::t_uint number_of_wavelet_coefficients = image.size();
 
  122                        fb, 
l1_norm, number_of_wavelet_coefficients)
 
  126                        .relative_variation(1e-3)
 
  127                        .objective_variation(1e-3);
 
  128   auto diagnostic = joint_map();
 
  129   SOPT_HIGH_LOG(
"Forward backward returned {}", diagnostic.good);
 
  130   if (output != 
"none")
 
  136   if (not diagnostic.good) 
throw std::runtime_error(
"Did not converge!");
 
  138   SOPT_HIGH_LOG(
"SOPT-Forward Backward converged in {} iterations", diagnostic.niters);
 
An operator that samples a set of measurements.
 
std::unique_ptr< std::mt19937_64 > mersenne(new std::mt19937_64(0))
 
#define SOPT_LOW_LOG(...)
Low priority message.
 
#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)
 
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)
 
real_type< typename T0::Scalar >::type l1_norm(Eigen::ArrayBase< T0 > const &input, Eigen::ArrayBase< T1 > const &weights)
Computes weighted L1 norm.
 
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