/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/gamma_contrast_host.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/gamma_contrast_host.hpp Source File#

2 min read time

Applies to Linux

rocCV: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/gamma_contrast_host.hpp Source File
gamma_contrast_host.hpp
Go to the documentation of this file.
1 
23 #pragma once
24 
25 #include <hip/hip_runtime.h>
27 #include "core/detail/casting.hpp"
28 
29 #include "operator_types.h"
30 
31 namespace Kernels {
32 namespace Host {
33 template <typename SrcWrapper, typename DstWrapper>
34 void gamma_contrast(SrcWrapper input, DstWrapper output, float gamma) {
35  using namespace roccv::detail; // For RangeCast, NumElements, etc.
36  using src_type = typename SrcWrapper::ValueType;
37  using dst_type = typename DstWrapper::ValueType;
38  using work_type = MakeType<float, NumElements<src_type>>;
39 
40  for (int batch = 0; batch < output.batches(); batch++) {
41 #pragma omp parallel for
42  for (int y = 0; y < output.height(); y++) {
43  for (int x = 0; x < output.width(); x++) {
44  auto inVal = (RangeCast<work_type>(input.at(batch, y, x, 0)));
45  work_type result = math::vpowf(inVal, gamma);
46  if constexpr (NumElements<dst_type> == 4) {
47  output.at(batch, y, x, 0) = RangeCast<dst_type>((MakeType<float, 4>){result.x, result.y, result.z, inVal.w});
48  } else {
49  output.at(batch, y, x, 0) = RangeCast<dst_type>(result);
50  }
51  }
52  }
53  }
54 }
55 } // namespace Host
56 } // namespace Kernels
void gamma_contrast(SrcWrapper input, DstWrapper output, float gamma)
Definition: gamma_contrast_host.hpp:34
Definition: non_max_suppression_helpers.hpp:26
Definition: strided_data_wrap.hpp:33
MakeType_t< T, C >::type MakeType
Definition: type_traits.hpp:97
This header defines common arithmetic operators for HIP vectorized types.