blob: 79c18fae9f7f75e6cf8fe127471d5624ba7d11af [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michalis Spyrouf4643372019-11-29 16:17:13 +00002 * Copyright (c) 2016-2019 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H
25#define ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/CL/kernels/CLHistogramKernel.h"
28#include "arm_compute/core/CL/kernels/CLTableLookupKernel.h"
29#include "arm_compute/runtime/CL/CLDistribution1D.h"
30#include "arm_compute/runtime/CL/CLLut.h"
31#include "arm_compute/runtime/IFunction.h"
32
33#include <cstdint>
34
35namespace arm_compute
36{
37class ICLTensor;
38using ICLImage = ICLTensor;
39
40/** Basic function to execute histogram equalization. This function calls the following CL kernels:
41 *
42 * -# @ref CLHistogramKernel
43 * -# @ref CLTableLookupKernel
44 *
45 */
46class CLEqualizeHistogram : public IFunction
47{
48public:
49 /** Default Constructor. */
50 CLEqualizeHistogram();
51 /** Initialise the kernel's inputs.
52 *
53 * @param[in] input Input image. Data types supported: U8.
54 * @param[out] output Output of same data type with equalized brightness and contrast.
55 */
56 void configure(const ICLImage *input, ICLImage *output);
57
58 // Inherited methods overridden:
59 void run() override;
60
61private:
62 CLHistogramKernel _histogram_kernel; /**< Kernel that calculates the histogram of input. */
63 CLHistogramBorderKernel _border_histogram_kernel; /**< Kernel that calculates the histogram on the borders. */
64 CLTableLookupKernel _map_histogram_kernel; /**< Kernel that maps the input to output using the lut. */
65 CLDistribution1D _hist; /**< Distribution that holds the histogram of the input image. */
66 CLDistribution1D _cum_dist; /**< Distribution that holds the cummulative distribution of the input histogram. */
67 CLLut _cd_lut; /**< Holds the equalization lookuptable. */
68 static const uint32_t max_range = 256; /**< Histogram range of the internal histograms. */
69 static const uint32_t nr_bins = 256; /**< Histogram bins of the internal histograms. */
70};
71}
Michalis Spyrouf4643372019-11-29 16:17:13 +000072#endif /*ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H */