Compute Library
 21.02
NEEqualizeHistogram.cpp
Go to the documentation of this file.
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  */
25 
28 #include "arm_compute/core/Types.h"
35 
36 namespace arm_compute
37 {
39 
41  : _histogram_kernel(), _cd_histogram_kernel(), _map_histogram_kernel(), _hist(nr_bins, 0, max_range), _cum_dist(nr_bins, 0, max_range), _cd_lut(nr_bins, DataType::U8)
42 {
43 }
44 
46 {
51 
52  _histogram_kernel = std::make_unique<NEHistogramKernel>();
53  _cd_histogram_kernel = std::make_unique<NECumulativeDistributionKernel>();
54  _map_histogram_kernel = std::make_unique<NETableLookupKernel>();
55 
56  // Configure kernels
57  _histogram_kernel->configure(input, &_hist);
58  _cd_histogram_kernel->configure(input, &_hist, &_cum_dist, &_cd_lut);
59  _map_histogram_kernel->configure(input, &_cd_lut, output);
60 }
61 
63 {
64  // Calculate histogram of input.
65  NEScheduler::get().schedule(_histogram_kernel.get(), Window::DimY);
66 
67  // Calculate cumulative distribution of histogram and create LUT.
68  NEScheduler::get().schedule(_cd_histogram_kernel.get(), Window::DimY);
69 
70  // Map input to output using created LUT.
71  NEScheduler::get().schedule(_map_histogram_kernel.get(), Window::DimY);
72 }
73 } // namespace arm_compute
~NEEqualizeHistogram()
Default destructor.
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
Definition: Validate.h:856
void configure(const IImage *input, IImage *output)
Initialise the kernel&#39;s inputs.
1 channel, 1 U8 per channel
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
NEEqualizeHistogram()
Default Constructor.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
DataType
Available data types.
Definition: Types.h:77
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94