37 const size_t num_bins = 256;
39 std::vector<T> lut(num_bins);
40 std::vector<uint32_t> hist(num_bins);
41 std::vector<uint32_t> cd(num_bins);
46 for(
int element_idx = 0; element_idx < src.
num_elements(); ++element_idx)
48 hist[src[element_idx]]++;
52 std::partial_sum(hist.begin(), hist.end(), cd.begin());
55 const uint32_t cd_min = *std::find_if(hist.begin(), hist.end(), [](
const uint32_t &x)
60 const size_t total_num_pixels = cd.back();
63 if(total_num_pixels == cd_min)
65 std::iota(lut.begin(), lut.end(), 0);
69 const float diff = total_num_pixels - 1;
71 for(
size_t i = 0; i < num_bins; ++i)
73 lut[i] = lround((cd[i] - cd_min) / diff * 255.f);
DataType data_type() const override
Data type of the tensor.
TensorShape shape() const override
Shape of the tensor.
This file contains all available output stages for GEMMLowp on OpenCL.
Simple tensor object that stores elements in a consecutive chunk of memory.
int num_elements() const override
Number of elements of the tensor.
SimpleTensor< T > equalize_histogram(const SimpleTensor< T > &src)
convolution configure & src