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));
 
   59   SOPT_HIGH_LOG(
"Image size: {} x {} = {}", image.cols(), image.rows(), image.size());
 
   62   sopt::t_uint const nmeasure = std::floor(0.33 * image.size());
 
   71   auto const psi = sopt::linear_transform<Scalar>(wavelet, image.rows(), image.cols());
 
   72   SOPT_LOW_LOG(
"Wavelet coefficients: {}", (psi.adjoint() * image).size());
 
   75   Vector const y0 = sampling * Vector::Map(image.data(), image.size());
 
   76   auto constexpr snr = 30.0;
 
   77   auto const sigma = y0.stableNorm() / std::sqrt(y0.size()) * std::pow(10.0, -(snr / 20.0));
 
   78   auto const epsilon = std::sqrt(nmeasure + 2 * std::sqrt(nmeasure)) * 
sigma;
 
   81   std::normal_distribution<> gaussian_dist(0, 
sigma);
 
   85   if (output != 
"none") {
 
   88                                 "dirty_" + output + 
".tiff");
 
   98     .regulariser_strength(regulariser_strength)
 
   99     .relative_variation(5e-4)
 
  100     .residual_tolerance(0)
 
  106   auto gp = std::make_shared<sopt::algorithm::L1GProximal<Scalar>>(
false);
 
  107   gp->l1_proximal_tolerance(1e-4)
 
  109     .l1_proximal_itermax(50)
 
  110     .l1_proximal_positivity_constraint(
true)
 
  111     .l1_proximal_real_constraint(
true)
 
  120   auto const diagnostic = fb();
 
  121   SOPT_HIGH_LOG(
"Forward backward returned {}", diagnostic.good);
 
  123   if (output != 
"none")
 
  129   if (not diagnostic.good) 
throw std::runtime_error(
"Did not converge!");
 
  131   SOPT_HIGH_LOG(
"SOPT-Forward Backward converged in {} iterations", diagnostic.niters);
 
  136   const std::function<
Scalar(
Vector)> objective_function = [regulariser_strength, 
sigma, &y, &sampling,
 
  138     return sopt::l1_norm(psi.adjoint() * x) * regulariser_strength +
 
  145   std::tie(lower_error, mean_solution, upper_error) =
 
  146       sopt::credible_region::credible_interval<sopt::Vector<sopt::t_real>, 
sopt::t_real>(
 
  147           diagnostic.x, image.rows(), image.cols(), grid_pixel_size, objective_function, alpha);
 
  148   if (output != 
"none") {
 
  150         Matrix::Map(upper_error.data(), upper_error.rows(), upper_error.cols()),
 
  151         output + 
"_upper_error.tiff");
 
  153         Matrix::Map(mean_solution.data(), mean_solution.rows(), mean_solution.cols()),
 
  154         output + 
"_mean_solution.tiff");
 
  156         Matrix::Map(lower_error.data(), lower_error.rows(), lower_error.cols()),
 
  157         output + 
"_lower_error.tiff");
 
An operator that samples a set of measurements.
 
t_LinearTransform const  & Phi() const
Measurement operator.
 
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.
 
real_type< typename T0::Scalar >::type l2_norm(Eigen::ArrayBase< T0 > const &input, Eigen::ArrayBase< T1 > const &weights)
Computes weighted L2 norm.
 
sopt::Vector< Scalar > Vector
 
sopt::Matrix< Scalar > Matrix
 
sopt::Image< Scalar > Image