| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "klimenko_v_lsh_contrast_incr/omp/include/ops_omp.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "klimenko_v_lsh_contrast_incr/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace klimenko_v_lsh_contrast_incr { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | KlimenkoVLSHContrastIncrOMP::KlimenkoVLSHContrastIncrOMP(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | GetInput() = in; |
| 14 | 12 | } | |
| 15 | |||
| 16 | 12 | bool KlimenkoVLSHContrastIncrOMP::ValidationImpl() { | |
| 17 | 12 | return !GetInput().empty(); | |
| 18 | } | ||
| 19 | |||
| 20 | 12 | bool KlimenkoVLSHContrastIncrOMP::PreProcessingImpl() { | |
| 21 | 12 | GetOutput().resize(GetInput().size()); | |
| 22 | 12 | return true; | |
| 23 | } | ||
| 24 | |||
| 25 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | bool KlimenkoVLSHContrastIncrOMP::RunImpl() { |
| 26 | const auto &input = GetInput(); | ||
| 27 | auto &output = GetOutput(); | ||
| 28 | |||
| 29 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (input.empty()) { |
| 30 | return false; | ||
| 31 | } | ||
| 32 | |||
| 33 | const size_t size = input.size(); | ||
| 34 | |||
| 35 | 12 | int min_val = input[0]; | |
| 36 | int max_val = input[0]; | ||
| 37 | |||
| 38 | 12 | #pragma omp parallel for default(none) shared(input, size) reduction(min : min_val) reduction(max : max_val) | |
| 39 | for (size_t i = 0; i < size; ++i) { | ||
| 40 | min_val = std::min(input[i], min_val); | ||
| 41 | max_val = std::max(input[i], max_val); | ||
| 42 | } | ||
| 43 | |||
| 44 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (max_val == min_val) { |
| 45 | ✗ | #pragma omp parallel for default(none) shared(input, output, size) | |
| 46 | for (size_t i = 0; i < size; ++i) { | ||
| 47 | output[i] = input[i]; | ||
| 48 | } | ||
| 49 | ✗ | return true; | |
| 50 | } | ||
| 51 | 12 | const int range = max_val - min_val; | |
| 52 | 12 | #pragma omp parallel for default(none) shared(input, output, size, min_val, range) | |
| 53 | for (size_t i = 0; i < size; ++i) { | ||
| 54 | output[i] = ((input[i] - min_val) * 255) / range; | ||
| 55 | } | ||
| 56 | 12 | return true; | |
| 57 | } | ||
| 58 | |||
| 59 | 12 | bool KlimenkoVLSHContrastIncrOMP::PostProcessingImpl() { | |
| 60 | 12 | return GetOutput().size() == GetInput().size(); | |
| 61 | } | ||
| 62 | |||
| 63 | } // namespace klimenko_v_lsh_contrast_incr | ||
| 64 |