File: multiscale_transforms.cc

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 (38 lines) | stat: -rw-r--r-- 1,228 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
// SPDX-License-Identifier: LGPL-3.0-only

#include "algorithms/multiscale/multiscale_transforms.h"

#include <schaapcommon/math/convolution.h>

using aocommon::Image;

namespace radler::algorithms::multiscale {

void MultiScaleTransforms::Transform(std::vector<Image>& images, Image& scratch,
                                     float scale) {
  size_t kernelSize;
  Image shape = MakeShapeFunction(scale, kernelSize);

  scratch = 0.0;

  schaapcommon::math::PrepareSmallConvolutionKernel(
      scratch.Data(), _width, _height, shape.Data(), kernelSize);
  for (Image& image : images) {
    schaapcommon::math::Convolve(image.Data(), scratch.Data(), _width, _height);
  }
}

void MultiScaleTransforms::PrepareTransform(float* kernel, float scale) {
  size_t kernelSize;
  Image shape = MakeShapeFunction(scale, kernelSize);

  std::fill_n(kernel, _width * _height, 0.0);

  schaapcommon::math::PrepareSmallConvolutionKernel(kernel, _width, _height,
                                                    shape.Data(), kernelSize);
}

void MultiScaleTransforms::FinishTransform(float* image, const float* kernel) {
  schaapcommon::math::Convolve(image, kernel, _width, _height);
}
}  // namespace radler::algorithms::multiscale