43 : _input(nullptr), _distribution(nullptr), _cumulative_sum(nullptr), _output(nullptr)
66 _cumulative_sum = cumulative_sum;
84 const uint32_t *hist = _distribution->
buffer();
85 uint32_t *cumulative_sum = _cumulative_sum->
buffer();
86 uint8_t *output = _output->
buffer();
89 std::partial_sum(hist, hist + _histogram_size, cumulative_sum);
92 const uint32_t cd_min = *std::find_if(hist, hist + _histogram_size, [](
const uint32_t &v)
96 const uint32_t image_size = cumulative_sum[_histogram_size - 1];
101 if(image_size == cd_min)
103 std::iota(output, output + _histogram_size, 0);
107 const float diff = image_size - cd_min;
109 for(
unsigned int x = 0; x < _histogram_size; ++x)
111 output[x] = lround((cumulative_sum[x] - cd_min) / diff * 255.0f);
bool set_format_if_unknown(ITensorInfo &info, Format format)
Set the format, data type and number of channels to the specified value if the current data type is u...
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
1 channel, 1 U8 per channel
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Interface for Neon tensor.
virtual size_t num_elements() const =0
Returns the total number of elements in the LUT.
Copyright (c) 2017-2021 Arm Limited.
virtual uint32_t * buffer() const =0
Returns a pointer to the start of the distribution.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
1D Distribution interface
Lookup Table object interface.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
bool is_parallelisable() const override
Indicates whether or not the kernel is parallelisable.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
std::uniform_real_distribution< float > distribution(-5.f, 5.f)
void configure(const IImage *input, const IDistribution1D *distribution, IDistribution1D *cumulative_sum, ILut *output)
Set the input and output distribution.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
size_t num_bins() const
Returns the number of bins that the distribution has.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
virtual DataType type() const =0
Returns the type of the LUT.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
virtual uint8_t * buffer() const =0
Returns a pointer to the start of the LUT.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
NECumulativeDistributionKernel()
Default constructor.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)