File: threaded_deconvolution_tools.h

package info (click to toggle)
wsclean 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 129,246; python: 22,066; sh: 360; ansic: 230; makefile: 185
file content (54 lines) | stat: -rw-r--r-- 1,722 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
// SPDX-License-Identifier: LGPL-3.0-only

#ifndef RADLER_ALGORITHMS_THREADED_DECONVOLUTION_TOOLS_H_
#define RADLER_ALGORITHMS_THREADED_DECONVOLUTION_TOOLS_H_

#include <cmath>
#include <thread>
#include <vector>

#include <aocommon/image.h>
#include <aocommon/lane.h>
#include <aocommon/optionalnumber.h>
#include <aocommon/uvector.h>

#include "algorithms/multiscale/multiscale_transforms.h"

namespace radler::algorithms {

class ThreadedDeconvolutionTools {
 public:
  struct PeakData {
    aocommon::OptionalNumber<float> normalized_value;
    aocommon::OptionalNumber<float> unnormalized_value;
    float rms;
    size_t x;
    size_t y;
  };

  void SubtractImage(float* image, const aocommon::Image& psf, size_t x,
                     size_t y, float factor);

  void FindMultiScalePeak(
      multiscale::MultiScaleTransforms* ms_transforms,
      const aocommon::Image& image, const aocommon::UVector<float>& scales,
      std::vector<PeakData>& results, bool allowNegativeComponents,
      const bool* mask, const std::vector<aocommon::UVector<bool>>& scaleMasks,
      float borderRatio, const aocommon::Image& rmsFactorImage,
      bool calculateRMS);

  static float RMS(const aocommon::Image& image, size_t n) {
    float result = 0.0;
    for (size_t i = 0; i != n; ++i) result += image[i] * image[i];
    return std::sqrt(result / float(n));
  }

 private:
  ThreadedDeconvolutionTools::PeakData FindSingleScalePeak(
      multiscale::MultiScaleTransforms* ms_transforms, aocommon::Image& image,
      float scale, bool allow_negative_components, const bool* mask,
      float border_ratio, const aocommon::Image& rms_factor_image,
      bool calculate_rms);
};
}  // namespace radler::algorithms
#endif