File: histogram_equalisation.cc

package info (click to toggle)
purify 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 182,264 kB
  • sloc: cpp: 16,485; python: 449; xml: 182; makefile: 7; sh: 6
file content (25 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "purify/config.h"
#include "purify/types.h"
#include "purify/cimg.h"
#include "purify/directories.h"
#include "purify/pfitsio.h"
using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
  // up samples M31 example
  auto const input_name =
      (nargs > 1) ? static_cast<std::string>(args[1]) : image_filename("M31.fits");
  auto const output_name = (nargs > 2) ? static_cast<std::string>(args[2]) : "M31_heq.fits";
  Image<t_real> const input = pfitsio::read2d(input_name).real();
#ifdef PURIFY_CImg
  CDisplay display = cimg::make_display<Image<t_real>>(input, "Image");
  const auto img1 = cimg::make_image(input.real().eval()).get_normalize(0, 1);
  const auto results = img1.get_equalize(256, 0.01, 1);
  const Image<t_real> &output = Image<t_real>::Map(reinterpret_cast<const t_real *>(results.data()),
                                                   input.rows(), input.cols());
  pfitsio::write2d(output, output_name);
#else
  throw std::runtime_error("compile with CImg.");
#endif
}