49 const uint32_t *dist_ptr = dist.
buffer();
50 uint32_t *cum_dist_ptr = cum_dist.
buffer();
51 uint8_t *lut_ptr = lut.
buffer();
58 std::partial_sum(dist_ptr, dist_ptr + 256, cum_dist_ptr);
61 const uint32_t num_lowest_pixels = *std::find_if(dist_ptr, dist_ptr + 256, [](
const uint32_t &v)
65 const size_t image_size = cum_dist_ptr[255];
67 if(image_size == num_lowest_pixels)
69 std::iota(lut_ptr, lut_ptr + 256, 0);
73 const float diff = image_size - num_lowest_pixels;
75 for(
size_t i = 0; i < 256; ++i)
77 lut_ptr[i] = lround((cum_dist_ptr[i] - num_lowest_pixels) / diff * 255.f);
91 _hist(nr_bins, 0, max_range),
92 _cum_dist(nr_bins, 0, max_range),
106 _histogram_kernel->configure(compile_context, input, &_hist);
107 _border_histogram_kernel->configure(compile_context, input, &_hist);
108 _map_histogram_kernel->configure(compile_context, input, &_cd_lut, output);
120 calculate_cum_dist_and_lut(_hist, _cum_dist, _cd_lut);
Interface for the kernel to perform table lookup calculations.
CLEqualizeHistogram()
Default Constructor.
static CLScheduler & get()
Access the scheduler singleton.
void configure(const ICLImage *input, ICLImage *output)
Initialise the kernel's inputs.
void unmap()
Enqueue an unmap operation of the allocated and mapped buffer.
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.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
CLDistribution1D object class.
Copyright (c) 2017-2021 Arm Limited.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
void map(bool blocking=true)
Enqueue a map operation of the allocated buffer.
Interface to run the histogram kernel.
uint8_t * buffer() const override
Returns a pointer to the start of the LUT.
void unmap()
Enqueue an unmap operation of the allocated and mapped buffer.
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
uint32_t * buffer() const override
Returns a pointer to the start of the distribution.
Interface for OpenCL tensor.
Wrapper to configure the Khronos OpenCL C++ header.
Interface to run the histogram kernel to handle the leftover part of image.
void run() override
Run the kernels contained in the function.
Basic implementation of the OpenCL lut interface.
DataType
Available data types.
void map(bool blocking=true)
Enqueue a map operation of the allocated buffer.
~CLEqualizeHistogram()
Default destructor.