| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gutyansky_a_img_contrast_incr/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <limits> | ||
| 7 | |||
| 8 | #include "gutyansky_a_img_contrast_incr/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace gutyansky_a_img_contrast_incr { | ||
| 11 | |||
| 12 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | GutyanskyAImgContrastIncrSEQ::GutyanskyAImgContrastIncrSEQ(const InType &in) { |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | GetInput() = in; |
| 15 | GetOutput() = {}; | ||
| 16 | 80 | } | |
| 17 | |||
| 18 | 80 | bool GutyanskyAImgContrastIncrSEQ::ValidationImpl() { | |
| 19 | 80 | return !GetInput().empty(); | |
| 20 | } | ||
| 21 | |||
| 22 | 80 | bool GutyanskyAImgContrastIncrSEQ::PreProcessingImpl() { | |
| 23 | 80 | GetOutput().resize(GetInput().size()); | |
| 24 | 80 | return true; | |
| 25 | } | ||
| 26 | |||
| 27 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 48 times.
|
80 | bool GutyanskyAImgContrastIncrSEQ::RunImpl() { |
| 28 | 80 | const auto bounds = std::minmax_element(GetInput().begin(), GetInput().end()); | |
| 29 | 80 | uint8_t lower_bound = *bounds.first; | |
| 30 | 80 | uint8_t upper_bound = *bounds.second; | |
| 31 | 80 | uint8_t delta = upper_bound - lower_bound; | |
| 32 | |||
| 33 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 48 times.
|
80 | if (delta == 0) { |
| 34 | 32 | std::copy(GetInput().begin(), GetInput().end(), GetOutput().begin()); | |
| 35 | } else { | ||
| 36 | size_t sz = GetInput().size(); | ||
| 37 |
2/2✓ Branch 0 taken 232 times.
✓ Branch 1 taken 48 times.
|
280 | for (size_t i = 0; i < sz; i++) { |
| 38 | 232 | auto old_value = static_cast<uint16_t>(GetInput()[i]); | |
| 39 | 232 | uint16_t new_value = (std::numeric_limits<uint8_t>::max() * (old_value - lower_bound)) / delta; | |
| 40 | |||
| 41 | 232 | GetOutput()[i] = static_cast<uint8_t>(new_value); | |
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | 80 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 | 80 | bool GutyanskyAImgContrastIncrSEQ::PostProcessingImpl() { | |
| 49 | 80 | return true; | |
| 50 | } | ||
| 51 | |||
| 52 | } // namespace gutyansky_a_img_contrast_incr | ||
| 53 |