| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "zaharov_g_linear_contrast_stretch/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "zaharov_g_linear_contrast_stretch/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace zaharov_g_linear_contrast_stretch { | ||
| 11 | |||
| 12 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | ZaharovGLinContrStrSEQ::ZaharovGLinContrStrSEQ(const InType &in) { |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GetInput() = in; |
| 15 | 32 | } | |
| 16 | |||
| 17 | 32 | bool ZaharovGLinContrStrSEQ::ValidationImpl() { | |
| 18 | 32 | return !GetInput().empty(); | |
| 19 | } | ||
| 20 | |||
| 21 | 32 | bool ZaharovGLinContrStrSEQ::PreProcessingImpl() { | |
| 22 | 32 | GetOutput().resize(GetInput().size()); | |
| 23 | 32 | return true; | |
| 24 | } | ||
| 25 | |||
| 26 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
|
32 | bool ZaharovGLinContrStrSEQ::RunImpl() { |
| 27 | const InType &input = GetInput(); | ||
| 28 | OutType &output = GetOutput(); | ||
| 29 | |||
| 30 | auto [min_it, max_it] = std::ranges::minmax_element(input); | ||
| 31 | 32 | uint8_t min_el = *min_it; | |
| 32 | 32 | uint8_t max_el = *max_it; | |
| 33 | |||
| 34 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
|
32 | if (max_el > min_el) { |
| 35 | 24 | int denom = max_el - min_el; | |
| 36 | |||
| 37 |
2/2✓ Branch 0 taken 10072 times.
✓ Branch 1 taken 24 times.
|
10096 | for (size_t i = 0; i < input.size(); ++i) { |
| 38 | 10072 | int value = (static_cast<int>(input[i]) - min_el) * 255 / denom; | |
| 39 | 10072 | output[i] = static_cast<uint8_t>(std::clamp(value, 0, 255)); | |
| 40 | } | ||
| 41 | } else { | ||
| 42 | 8 | output.assign(input.begin(), input.end()); | |
| 43 | } | ||
| 44 | |||
| 45 | 32 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 | 32 | bool ZaharovGLinContrStrSEQ::PostProcessingImpl() { | |
| 49 | 32 | return !GetOutput().empty(); | |
| 50 | } | ||
| 51 | |||
| 52 | } // namespace zaharov_g_linear_contrast_stretch | ||
| 53 |