2 * Copyright (c) 2016, 2017 ARM Limited.
4 * SPDX-License-Identifier: MIT
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:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
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
24 #ifndef __ARM_COMPUTE_NEEQUALIZEHISTOGRAM_H__
25 #define __ARM_COMPUTE_NEEQUALIZEHISTOGRAM_H__
27 #include "arm_compute/core/NEON/kernels/NECumulativeDistributionKernel.h"
28 #include "arm_compute/core/NEON/kernels/NEHistogramKernel.h"
29 #include "arm_compute/core/NEON/kernels/NETableLookupKernel.h"
30 #include "arm_compute/runtime/Distribution1D.h"
31 #include "arm_compute/runtime/IFunction.h"
32 #include "arm_compute/runtime/Lut.h"
39 using IImage = ITensor;
41 /** Basic function to execute histogram equalization. This function calls the following NEON kernels:
43 * -# @ref NEHistogramKernel
44 * -# @ref NECumulativeDistributionKernel
45 * -# @ref NETableLookupKernel
48 class NEEqualizeHistogram : public IFunction
51 /** Default Constructor. */
52 NEEqualizeHistogram();
53 /** Initialise the kernel's inputs.
55 * @note Currently the width of the input image must be a multiple of 16.
57 * @param[in] input Input image. Data type supported: U8.
58 * @param[out] output Output image. Data type supported: same as @p input
60 void configure(const IImage *input, IImage *output);
62 // Inherited methods overridden:
66 NEHistogramKernel _histogram_kernel; /**< Kernel that calculates the histogram of input. */
67 NEHistogramBorderKernel _border_histogram_kernel; /**< Kernel that calculates the histogram on the borders. */
68 NECumulativeDistributionKernel _cd_histogram_kernel; /**< Kernel that calculates the cumulative distribution
69 and creates the relevant LookupTable. */
70 NETableLookupKernel _map_histogram_kernel; /**< Kernel that maps the input to output using the lut. */
71 Distribution1D _hist; /**< Distribution that holds the histogram of the input image. */
72 Distribution1D _cum_dist; /**< Distribution that holds the cummulative distribution of the input histogram. */
73 Lut _cd_lut; /**< Holds the equalization lookuptable. */
74 bool _run_border_hist; /**< Boolean that specifies if a separate histogram kernel has to run on the borders */
76 static constexpr uint32_t nr_bins{ 256 }; /**< Histogram bins of the internal histograms. */
77 static constexpr uint32_t max_range{ nr_bins - 1 }; /**< Histogram range of the internal histograms. */
80 #endif /*__ARM_COMPUTE_NEEQUALIZEHISTOGRAM_H__ */