PURIFY
Next-generation radio interferometric imaging
wavelet_decomposition.cc
Go to the documentation of this file.
1 #include "purify/config.h"
2 #include "purify/types.h"
3 #include "purify/directories.h"
4 #include "purify/logging.h"
5 #include "purify/pfitsio.h"
6 #include "purify/utilities.h"
8 
9 using namespace purify;
10 
11 int main(int nargs, char const **args) {
13  auto const input_name =
14  (nargs > 1) ? static_cast<std::string>(args[1]) : image_filename("M31.fits");
15  auto const output_name =
16  (nargs > 2) ? static_cast<std::string>(args[2]) : "wavelet_decomposition.fits";
17 #define ARGS_MACRO(NAME, ARGN, VALUE, TYPE) \
18  auto const NAME = \
19  static_cast<TYPE>((nargs > ARGN) ? std::stod(static_cast<std::string>(args[ARGN])) : VALUE);
20 
21  ARGS_MACRO(levels, 4, 3, t_uint)
22  Image<t_complex> const ground_truth_image = pfitsio::read2d(input_name).cast<t_complex>();
23 
24  const std::vector<std::tuple<std::string, t_uint>> wavelets{
25  std::make_tuple("Dirac", levels), std::make_tuple("DB1", levels),
26  std::make_tuple("DB2", levels), std::make_tuple("DB3", levels),
27  std::make_tuple("DB4", levels), std::make_tuple("DB5", levels),
28  std::make_tuple("DB6", levels), std::make_tuple("DB7", levels),
29  std::make_tuple("DB8", levels)};
30 
31  const auto phi = factory::wavelet_operator_factory<Vector<t_complex>>(
32  factory::distributed_wavelet_operator::serial, wavelets, ground_truth_image.rows(),
33  ground_truth_image.cols());
34  const Image<t_complex> decompostion =
35  Image<t_complex>::Map((phi->adjoint() * Vector<t_complex>::Map(ground_truth_image.data(),
36  ground_truth_image.size()))
37  .eval()
38  .data(),
39  ground_truth_image.rows(), ground_truth_image.cols() * wavelets.size());
40  pfitsio::write2d(decompostion.real(), output_name);
41 }
void set_level(const std::string &level)
Method to set the logging level of the default Log object.
Definition: logging.h:137
void write2d(const Image< t_real > &eigen_image, const pfitsio::header_params &header, const bool &overwrite)
Write image to fits file.
Definition: pfitsio.cc:30
Image< t_complex > read2d(const std::string &fits_name)
Read image from fits file.
Definition: pfitsio.cc:109
std::string image_filename(std::string const &filename)
Image filename.
#define ARGS_MACRO(NAME, ARGN, VALUE, TYPE)
int main(int nargs, char const **args)