• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016-2020 Arm Limited.
3  *
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  */
24 #ifndef ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H
25 #define ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H
26 
27 #include "arm_compute/runtime/CL/CLDistribution1D.h"
28 #include "arm_compute/runtime/CL/CLLut.h"
29 #include "arm_compute/runtime/IFunction.h"
30 
31 #include <cstdint>
32 #include <memory>
33 
34 namespace arm_compute
35 {
36 class CLCompileContext;
37 class CLHistogramKernel;
38 class CLHistogramBorderKernel;
39 class CLTableLookupKernel;
40 class ICLTensor;
41 using ICLImage = ICLTensor;
42 
43 /** Basic function to execute histogram equalization. This function calls the following CL kernels:
44  *
45  * -# @ref CLHistogramKernel
46  * -# @ref CLTableLookupKernel
47  *
48  * @deprecated This function is deprecated and is intended to be removed in 21.05 release
49  *
50  */
51 class CLEqualizeHistogram : public IFunction
52 {
53 public:
54     /** Default Constructor. */
55     CLEqualizeHistogram();
56     /** Prevent instances of this class from being copied */
57     CLEqualizeHistogram(const CLEqualizeHistogram &) = delete;
58     /** Prevent instances of this class from being copied */
59     CLEqualizeHistogram &operator=(const CLEqualizeHistogram &) = delete;
60     /** Default destructor */
61     ~CLEqualizeHistogram();
62     /** Initialise the kernel's inputs.
63      *
64      * @param[in]  input  Input image. Data types supported: U8.
65      * @param[out] output Output of same data type with equalized brightness and contrast.
66      */
67     void configure(const ICLImage *input, ICLImage *output);
68     /** Initialise the kernel's inputs.
69      *
70      * @param[in]  compile_context The compile context to be used.
71      * @param[in]  input           Input image. Data types supported: U8.
72      * @param[out] output          Output of same data type with equalized brightness and contrast.
73      */
74     void configure(const CLCompileContext &compile_context, const ICLImage *input, ICLImage *output);
75 
76     // Inherited methods overridden:
77     void run() override;
78 
79 private:
80     std::unique_ptr<CLHistogramKernel>       _histogram_kernel;        /**< Kernel that calculates the histogram of input. */
81     std::unique_ptr<CLHistogramBorderKernel> _border_histogram_kernel; /**< Kernel that calculates the histogram on the borders. */
82     std::unique_ptr<CLTableLookupKernel>     _map_histogram_kernel;    /**< Kernel that maps the input to output using the lut. */
83     CLDistribution1D                         _hist;                    /**< Distribution that holds the histogram of the input image. */
84     CLDistribution1D                         _cum_dist;                /**< Distribution that holds the cummulative distribution of the input histogram. */
85     CLLut                                    _cd_lut;                  /**< Holds the equalization lookuptable. */
86     static const uint32_t                    max_range = 256;          /**< Histogram range of the internal histograms. */
87     static const uint32_t                    nr_bins   = 256;          /**< Histogram bins of the internal histograms. */
88 };
89 }
90 #endif /*ARM_COMPUTE_CLEQUALIZEHISTOGRAM_H */
91