blob: 6cf800848005956f6c2be737012b04e8c26ec0df [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 2017 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_NEEQUALIZEHISTOGRAM_H__
25#define __ARM_COMPUTE_NEEQUALIZEHISTOGRAM_H__
26
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"
33
34#include <cstdint>
35
36namespace arm_compute
37{
38class ITensor;
39using IImage = ITensor;
40
41/** Basic function to execute histogram equalization. This function calls the following NEON kernels:
42 *
43 * -# @ref NEHistogramKernel
44 * -# @ref NECumulativeDistributionKernel
45 * -# @ref NETableLookupKernel
46 *
47 */
48class NEEqualizeHistogram : public IFunction
49{
50public:
51 /** Default Constructor. */
52 NEEqualizeHistogram();
53 /** Initialise the kernel's inputs.
54 *
55 * @note Currently the width of the input image must be a multiple of 16.
56 *
57 * @param[in] input Input image. Data type supported: U8.
58 * @param[out] output Output image. Data type supported: same as @p input
59 */
60 void configure(const IImage *input, IImage *output);
61
62 // Inherited methods overridden:
63 void run() override;
64
65private:
66 NEHistogramKernel _histogram_kernel; /**< Kernel that calculates the histogram of input. */
67 NECumulativeDistributionKernel _cd_histogram_kernel; /**< Kernel that calculates the cumulative distribution
68 and creates the relevant LookupTable. */
69 NETableLookupKernel _map_histogram_kernel; /**< Kernel that maps the input to output using the lut. */
70 Distribution1D _hist; /**< Distribution that holds the histogram of the input image. */
71 Distribution1D _cum_dist; /**< Distribution that holds the cummulative distribution of the input histogram. */
72 Lut _cd_lut; /**< Holds the equalization lookuptable. */
73 static constexpr uint32_t nr_bins{ 256 }; /**< Histogram bins of the internal histograms. */
74 static constexpr uint32_t max_range{ nr_bins - 1 }; /**< Histogram range of the internal histograms. */
75};
76}
77#endif /*__ARM_COMPUTE_NEEQUALIZEHISTOGRAM_H__ */