File: thresholdconfig.h

package info (click to toggle)
aoflagger 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,868 kB
  • sloc: cpp: 52,164; python: 152; sh: 60; makefile: 17
file content (77 lines) | stat: -rw-r--r-- 2,376 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
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
75
76
77
#ifndef THRESHOLDCONFIG_H
#define THRESHOLDCONFIG_H

#include <vector>

#include "../../structures/image2d.h"
#include "../../structures/mask2d.h"

class ThresholdConfig {
 public:
  enum Method { SumThreshold, VarThreshold };
  enum Distribution { Uniform, Gaussian, Rayleigh };
  ThresholdConfig();

  void InitializeLengthsDefault(unsigned count = 0);

  void InitializeLengthsSingleSample();

  void InitializeThresholdsFromFirstThreshold(
      num_t firstThreshold, enum Distribution noiseDistribution);

  void Execute(const Image2D* image, Mask2D* mask, bool additive,
               num_t timeSensitivity, num_t frequencySensitivity) const;
  void ExecuteWithMissing(const Image2D* image, Mask2D* mask,
                          const Mask2D* missing, bool additive,
                          num_t timeSensitivity,
                          num_t frequencySensitivity) const;
  void SetVerbose(bool verbose) { _verbose = verbose; }
  void SetMethod(Method method) { _method = method; }

  num_t GetHorizontalThreshold(unsigned index) const {
    return _horizontalOperations[index].threshold;
  }

  num_t GetVerticalThreshold(unsigned index) const {
    return _verticalOperations[index].threshold;
  }

  void SetHorizontalThreshold(unsigned index, num_t threshold) {
    _horizontalOperations[index].threshold = threshold;
  }

  void SetVerticalThreshold(unsigned index, num_t threshold) {
    _verticalOperations[index].threshold = threshold;
  }

  size_t GetHorizontalLength(unsigned index) const {
    return _horizontalOperations[index].length;
  }

  size_t GetVerticalLength(unsigned index) const {
    return _verticalOperations[index].length;
  }

  size_t GetHorizontalOperations() const {
    return _horizontalOperations.size();
  }
  size_t GetVerticalOperations() const { return _horizontalOperations.size(); }
  void SetMinimumConnectedSamples(size_t val) { _minConnectedSamples = val; }
  void RemoveHorizontalOperations() { _horizontalOperations.clear(); }
  void RemoveVerticalOperations() { _verticalOperations.clear(); }

 private:
  struct ThresholdOperation {
    size_t length;
    num_t threshold;
    num_t rate;
  };
  std::vector<ThresholdOperation> _horizontalOperations;
  std::vector<ThresholdOperation> _verticalOperations;
  Method _method;
  Distribution _distribution;
  bool _verbose;
  size_t _minConnectedSamples;
};

#endif