21 #include "tools_for_tests/directories.h" 
   27 int main(
int argc, 
char const **argv) {
 
   40   std::string 
const input = argc >= 2 ? argv[1] : 
"cameraman256";
 
   41   std::string 
const output = argc == 3 ? argv[2] : 
"none";
 
   43     std::cout << 
"Usage:\n" 
   46               << 
" [input [output]]\n\n" 
   47                  "- input: path to the image to clean (or name of standard SOPT image)\n" 
   48                  "- output: filename pattern for output image\n";
 
   52   auto const seed = std::time(
nullptr);
 
   53   std::srand(
static_cast<unsigned int>(seed));
 
   54   std::mt19937 
mersenne(std::time(
nullptr));
 
   66   auto const psi = sopt::linear_transform<Scalar>(wavelet, image.rows(), image.cols());
 
   69   Vector const y0 = sampling * Vector::Map(image.data(), image.size());
 
   70   auto constexpr snr = 30.0;
 
   71   auto const sigma = y0.stableNorm() / std::sqrt(y0.size()) * std::pow(10.0, -(snr / 20.0));
 
   72   auto const epsilon = std::sqrt(nmeasure + 2 * std::sqrt(y0.size())) * 
sigma;
 
   75   std::normal_distribution<> gaussian_dist(0, 
sigma);
 
   79   if (output != 
"none") {
 
   82                                 "dirty_" + output + 
".tiff");
 
   90     SOPT_MEDIUM_LOG(
"||abs(x) - x||_2: {}", (x.array().abs().matrix() - x).stableNorm());
 
  103           .append(sopt::proximal::l1_norm<Scalar>, psi.adjoint(), psi)
 
  107           .append(sopt::proximal::positive_quadrant<Scalar>);
 
  113   using t_PosQuadSDMM = std::remove_const<decltype(posq)>::type;
 
  114   auto const min_delta = 
sigma * std::sqrt(y.size()) / std::sqrt(8 * image.size());
 
  117   auto set_weights = [](t_PosQuadSDMM &sdmm, 
Vector const &weights) {
 
  118     sdmm.algorithm().proximals(0) = [weights](
Vector &out, 
Scalar gamma, 
Vector const &x) {
 
  122   auto call_PsiT = [&psi](t_PosQuadSDMM 
const &, 
Vector const &x) -> 
Vector {
 
  123     return psi.adjoint() * x;
 
  127                               .min_delta(min_delta)
 
  131   auto warm_start = sdmm(Vector::Zero(image.size()));
 
  141   if (not result.good) 
throw std::runtime_error(
"Did not converge!");
 
  143   SOPT_HIGH_LOG(
"SOPT-SDMM converged in {} iterations", result.niters);
 
  144   if (output != 
"none")
 
An operator that samples a set of measurements.
 
bool is_converged(t_Vector const &x) const
Forwards to convergence function parameter.
 
SDMM< SCALAR > & conjugate_gradient(t_uint itermax, t_real tolerance)
Helps setup conjugate gradient.
 
Proximal for indicator function of L2 ball.
 
std::unique_ptr< std::mt19937_64 > mersenne(new std::mt19937_64(0))
 
int main(int argc, char const **argv)
 
#define SOPT_HIGH_LOG(...)
High priority message.
 
#define SOPT_MEDIUM_LOG(...)
Medium priority message.
 
Reweighted< ALGORITHM > reweighted(ALGORITHM const &algo, typename Reweighted< ALGORITHM >::t_SetWeights const &set_weights, typename Reweighted< ALGORITHM >::t_Reweightee const &reweightee)
Factory function to create an l0-approximation by reweighting an l1 norm.
 
Translation< FUNCTION, VECTOR > translate(FUNCTION const &func, VECTOR const &translation)
Translates given proximal by given vector.
 
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.
 
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > positive_quadrant(Eigen::DenseBase< T > const &input)
Expression to create projection onto positive quadrant.
 
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)
 
std::enable_if< std::is_arithmetic< SCALAR >::value or is_complex< SCALAR >::value, SCALAR >::type soft_threshhold(SCALAR const &x, typename real_type< SCALAR >::type const &threshhold)
abs(x) < threshhold ? 0: x - sgn(x) * threshhold
 
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