SOPT
Sparse OPTimisation
inpainting.h
Go to the documentation of this file.
1 #ifndef SOPT_TOOLS_FOR_TESTS_INPAINTING_H
2 #define SOPT_TOOLS_FOR_TESTS_INPAINTING_H
3 
4 #include "sopt/config.h"
5 #include <random>
7 #include "sopt/types.h"
8 
9 namespace sopt {
10 
11 template <typename T>
13  return sampling * Vector<T>::Map(image.data(), image.size());
14 }
15 
16 template <typename T>
18  sopt::Image<T> const &image) {
19  auto constexpr snr = 30.0;
20  auto const y0 = target(sampling, image);
21  return y0.stableNorm() / std::sqrt(y0.size()) * std::pow(10.0, -(snr / 20.0));
22 }
23 
24 template <typename T, typename RANDOM>
26  RANDOM &mersenne) {
27  // values near the mean are the most likely
28  // standard deviation affects the dispersion of generated values from the mean
29  auto const y0 = target(sampling, image);
30  std::normal_distribution<> gaussian_dist(0, sigma(sampling, image));
31  Vector<T> y(y0.size());
32  for (t_int i = 0; i < y0.size(); i++) y(i) = y0(i) + gaussian_dist(mersenne);
33 
34  return y;
35 }
36 
37 template <typename T>
39  sopt::Image<T> const &image) {
40  auto const y0 = target(sampling, image);
41  auto const nmeasure = y0.size();
42  return std::sqrt(nmeasure + 2 * std::sqrt(nmeasure)) * sigma(sampling, image);
43 }
44 } // namespace sopt
45 #endif
Joins together direct and indirect operators.
Computes inner-most element type.
Definition: real_type.h:42
std::unique_ptr< std::mt19937_64 > mersenne(new std::mt19937_64(0))
int t_int
Root of the type hierarchy for signed integers.
Definition: types.h:13
Vector< T > dirty(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image, RANDOM &mersenne)
Definition: inpainting.h:25
Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic > Image
A 2-dimensional list of elements of given type.
Definition: types.h:39
Vector< T > target(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Definition: inpainting.h:12
real_type< T >::type epsilon(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Definition: inpainting.h:38
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
Definition: types.h:24
real_type< T >::type sigma(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Definition: inpainting.h:17