File: highpassfilterexperiment.cpp

package info (click to toggle)
aoflagger 3.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,960 kB
  • sloc: cpp: 83,076; python: 10,187; sh: 260; makefile: 178
file content (74 lines) | stat: -rw-r--r-- 2,040 bytes parent folder | download | duplicates (2)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <boost/test/unit_test.hpp>

#include "../../algorithms/highpassfilter.h"

#include "../../util/rng.h"
#include "../../util/stopwatch.h"

#include <iostream>

using algorithms::HighPassFilter;

BOOST_AUTO_TEST_SUITE(high_pass_filter_experiment,
                      *boost::unit_test::label("experiment") *
                          boost::unit_test::disabled())

static void Initialize(Image2DPtr& image, Mask2DPtr& mask) {
  const size_t width = 10000, height = 256;
  image = Image2D::CreateUnsetImagePtr(width, height);
  mask = Mask2D::CreateUnsetMaskPtr(width, height);
  size_t i = 0;
  for (size_t y = 0; y < height; ++y) {
    for (size_t x = 0; x < width; ++x) {
      image->SetValue(x, y, i);
      mask->SetValue(x, y, (i % 25 == 0) || (y == 5));
      ++i;
    }
  }
}

static void InitializeFlagged(Image2DPtr& image, Mask2DPtr& mask) {
  const size_t width = 10000 / 3, height = 256 / 3;
  image = Image2D::CreateUnsetImagePtr(width, height);
  mask = Mask2D::CreateUnsetMaskPtr(width, height);
  size_t i = 0;
  for (size_t y = 0; y < height; ++y) {
    for (size_t x = 0; x < width; ++x) {
      image->SetValue(x, y, i);
      mask->SetValue(x, y, (i % 2 == 0) || (y == 5));
      ++i;
    }
  }
}

BOOST_AUTO_TEST_CASE(time_high_pass_filter) {
  Image2DPtr image;
  Mask2DPtr mask;
  Initialize(image, mask);

  HighPassFilter filter;
  filter.SetHWindowSize(21);
  filter.SetVWindowSize(41);
  filter.SetHKernelSigmaSq(2.5);
  filter.SetVKernelSigmaSq(5.0);
  Stopwatch watch(true);
  filter.ApplyHighPass(image, mask);
  std::cout << " time token: " << watch.ToString() << ' ';
}

BOOST_AUTO_TEST_CASE(time_flagged_high_pass_filter) {
  Image2DPtr image;
  Mask2DPtr mask;
  InitializeFlagged(image, mask);

  HighPassFilter filter;
  filter.SetHWindowSize(21);
  filter.SetVWindowSize(41);
  filter.SetHKernelSigmaSq(2.5);
  filter.SetVKernelSigmaSq(5.0);
  Stopwatch watch(true);
  filter.ApplyHighPass(image, mask);
  std::cout << " time token: " << watch.ToString() << ' ';
}

BOOST_AUTO_TEST_SUITE_END()