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