blob: 883f330b330c4e2103bc6613b0858e694366b839 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2016-2020 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);
Manuel Bottini2b84be52020-04-08 10:15:51 +010057 /** Initialise the kernel's inputs.
58 *
59 * @param[in] compile_context The compile context to be used.
60 * @param[in] input Input image. Data types supported: U8.
61 * @param[out] output Output of same data type with equalized brightness and contrast.
62 */
63 void configure(const CLCompileContext &compile_context, const ICLImage *input, ICLImage *output);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010064
65 // Inherited methods overridden:
66 void run() override;
67
68private:
69 CLHistogramKernel _histogram_kernel; /**< Kernel that calculates the histogram of input. */
70 CLHistogramBorderKernel _border_histogram_kernel; /**< Kernel that calculates the histogram on the borders. */
71 CLTableLookupKernel _map_histogram_kernel; /**< Kernel that maps the input to output using the lut. */
72 CLDistribution1D _hist; /**< Distribution that holds the histogram of the input image. */
73 CLDistribution1D _cum_dist; /**< Distribution that holds the cummulative distribution of the input histogram. */
74 CLLut _cd_lut; /**< Holds the equalization lookuptable. */
75 static const uint32_t max_range = 256; /**< Histogram range of the internal histograms. */
76 static const uint32_t nr_bins = 256; /**< Histogram bins of the internal histograms. */
77};
78}
Michalis Spyrouf4643372019-11-29 16:17:13 +000079#endif /*ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H */