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