Compute Library
 21.02
NELaplacianReconstruct Class Reference

Basic function to execute laplacian reconstruction. More...

#include <NELaplacianReconstruct.h>

Collaboration diagram for NELaplacianReconstruct:
[legend]

Public Member Functions

 NELaplacianReconstruct ()
 Constructor. More...
 
 NELaplacianReconstruct (const NELaplacianReconstruct &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NELaplacianReconstructoperator= (const NELaplacianReconstruct &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NELaplacianReconstruct (NELaplacianReconstruct &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NELaplacianReconstructoperator= (NELaplacianReconstruct &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NELaplacianReconstruct ()
 Default destructor. More...
 
void configure (const IPyramid *pyramid, ITensor *input, ITensor *output, BorderMode border_mode, uint8_t constant_border_value)
 Initialise the function's source, destinations and border mode. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Detailed Description

Basic function to execute laplacian reconstruction.

This function calls the following Neon kernels and functions:

  1. NEArithmeticAddition
  2. NEScale
  3. NEDepthConvertLayer

This function reconstructs the original image from a Laplacian Image Pyramid.

The input image is added to the last level of the Laplacian pyramid L(n-2), the resulting image is upsampled to the resolution of the next pyramid level.

I(n-2) = upsample( input + L(n-1)

For each pyramid level i, except i=0 and i=n-1: I(i-1) = upsample(I(i) + L(i))

output = I(0) + L(0)

Deprecated:
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 63 of file NELaplacianReconstruct.h.

Constructor & Destructor Documentation

◆ NELaplacianReconstruct() [1/3]

Constructor.

Definition at line 39 of file NELaplacianReconstruct.cpp.

40  : _tmp_pyr(),
41  _addf(),
42  _scalef(),
43  _depthf()
44 {
45 }

◆ NELaplacianReconstruct() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ NELaplacianReconstruct() [3/3]

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ ~NELaplacianReconstruct()

~NELaplacianReconstruct ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const IPyramid pyramid,
ITensor input,
ITensor output,
BorderMode  border_mode,
uint8_t  constant_border_value 
)

Initialise the function's source, destinations and border mode.

The Output image must have the same size as the first level of the pyramid. The Input image must have the same size as the last level of the pyramid.

The idea is to reconstuct the original hi-res image from a low-res representation of it and the laplacian pyramid.

Parameters
[in]pyramidLaplacian pyramid tensors, Data type supported at each level: S16.
[in]inputSource tensor. Data type supported: S16.
[out]outputOutput tensor. Data type supported: U8.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 47 of file NELaplacianReconstruct.cpp.

References Pyramid::allocate(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::CENTER, NEDepthConvertLayer::configure(), ITensorInfo::dimension(), IPyramid::get_pyramid_level(), Pyramid::get_pyramid_level(), ITensor::info(), IPyramid::info(), arm_compute::test::validation::info, Pyramid::init(), PyramidInfo::init(), arm_compute::NEAREST_NEIGHBOR, ITensorInfo::num_dimensions(), PyramidInfo::num_levels(), arm_compute::S16, arm_compute::SATURATE, ITensorInfo::tensor_shape(), and arm_compute::U8.

48 {
49  ARM_COMPUTE_ERROR_ON(nullptr == pyramid);
50  ARM_COMPUTE_ERROR_ON(input == output);
53  ARM_COMPUTE_ERROR_ON(input->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions());
54  ARM_COMPUTE_ERROR_ON(output->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions());
55  ARM_COMPUTE_ERROR_ON(output->info()->dimension(0) != pyramid->get_pyramid_level(0)->info()->dimension(0));
56  ARM_COMPUTE_ERROR_ON(output->info()->dimension(1) != pyramid->get_pyramid_level(0)->info()->dimension(1));
57  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(0));
58  ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(1));
59 
60  const size_t num_levels = pyramid->info()->num_levels();
61 
62  // Create and initialize the tmp pyramid: I(n-2) = upsample( input + Laplace(n-1) )
63  PyramidInfo pyramid_info;
64  pyramid_info.init(num_levels, 0.5f, output->info()->tensor_shape(), arm_compute::Format::S16);
65 
66  _tmp_pyr.init(pyramid_info);
67 
68  // Allocate add and scale functions. Level 0 does not need to be scaled.
69  _addf.resize(num_levels);
70  _scalef.resize(num_levels - 1);
71 
72  const size_t last_level = num_levels - 1;
73 
74  _addf[last_level].configure(input, pyramid->get_pyramid_level(last_level), _tmp_pyr.get_pyramid_level(last_level), ConvertPolicy::SATURATE);
75 
76  // Scale levels n-1 to 1, and add levels n-2 to 0
77  for(size_t l = 0; l < last_level; ++l)
78  {
79  _scalef[l].configure(_tmp_pyr.get_pyramid_level(l + 1), _tmp_pyr.get_pyramid_level(l), ScaleKernelInfo{ arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR, border_mode, constant_border_value, SamplingPolicy::CENTER, false });
80  _addf[l].configure(_tmp_pyr.get_pyramid_level(l), pyramid->get_pyramid_level(l), _tmp_pyr.get_pyramid_level(l), ConvertPolicy::SATURATE);
81  }
82 
83  // Convert level 0 from S16 to U8
84  _depthf.configure(_tmp_pyr.get_pyramid_level(0), output, ConvertPolicy::SATURATE, 0);
85 
86  _tmp_pyr.allocate();
87 }
Tensor * get_pyramid_level(size_t index) const override
Retrieves a level of the pyramid as a ITensor pointer.
Definition: Pyramid.cpp:112
1 channel, 1 U8 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Output values are defined to match the source pixel whose center is nearest to the sample position...
Samples are taken at pixel center.
void init(const PyramidInfo &info)
Initialize pyramid data-object using the given Pyramid&#39;s metadata.
Definition: Pyramid.cpp:35
void allocate()
Allocate the planes in the pyramid.
Definition: Pyramid.cpp:99
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void configure(const ITensor *input, ITensor *output, ConvertPolicy policy, uint32_t shift=0)
Initialize the function&#39;s source, destination.

◆ operator=() [1/2]

NELaplacianReconstruct& operator= ( const NELaplacianReconstruct )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

NELaplacianReconstruct& operator= ( NELaplacianReconstruct &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For Neon kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 89 of file NELaplacianReconstruct.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, Pyramid::info(), PyramidInfo::num_levels(), and INESimpleFunctionNoBorder::run().

90 {
91  ARM_COMPUTE_ERROR_ON_MSG(_addf.empty(), "Unconfigured function");
92 
93  const size_t last_level = _tmp_pyr.info()->num_levels() - 1;
94 
95  _addf[last_level].run();
96 
97  // Run l = [last_level - 1, 0]
98  for(size_t l = last_level; l-- > 0;)
99  {
100  _scalef[l].run();
101  _addf[l].run();
102  }
103 
104  _depthf.run();
105 }
void run() override final
Run the kernels contained in the function.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
const PyramidInfo * info() const override
Interface to be implemented by the child class to return the Pyramid&#39;s metadata.
Definition: Pyramid.cpp:107
size_t num_levels() const
Return the number of the pyramid levels.
Definition: PyramidInfo.cpp:77

The documentation for this class was generated from the following files: