| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "dorogin_v_contrast_enhancement/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | |||
| 7 | #include "dorogin_v_contrast_enhancement/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace dorogin_v_contrast_enhancement { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | DoroginVContrastEnhancementSEQ::DoroginVContrastEnhancementSEQ(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | GetInput() = in; |
| 14 | GetOutput() = {}; | ||
| 15 | 80 | } | |
| 16 | |||
| 17 | 80 | bool DoroginVContrastEnhancementSEQ::ValidationImpl() { | |
| 18 | 80 | return !GetInput().empty(); | |
| 19 | } | ||
| 20 | |||
| 21 | 80 | bool DoroginVContrastEnhancementSEQ::PreProcessingImpl() { | |
| 22 | 80 | image_ = GetInput(); | |
| 23 | 80 | result_.resize(image_.size()); | |
| 24 |
2/2✓ Branch 0 taken 8280 times.
✓ Branch 1 taken 80 times.
|
8360 | for (std::size_t i = 0; i < image_.size(); ++i) { |
| 25 | 8280 | result_[i] = 0; | |
| 26 | } | ||
| 27 | 80 | return true; | |
| 28 | } | ||
| 29 | |||
| 30 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | bool DoroginVContrastEnhancementSEQ::RunImpl() { |
| 31 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | if (image_.empty()) { |
| 32 | return true; | ||
| 33 | } | ||
| 34 | |||
| 35 | 80 | uint8_t min_val = *std::ranges::min_element(image_); | |
| 36 | 80 | uint8_t max_val = *std::ranges::max_element(image_); | |
| 37 | |||
| 38 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 64 times.
|
80 | if (min_val == max_val) { |
| 39 | 16 | result_ = image_; | |
| 40 | 16 | return true; | |
| 41 | } | ||
| 42 | |||
| 43 | 64 | int range = max_val - min_val; | |
| 44 |
2/2✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 64 times.
|
8304 | for (std::size_t i = 0; i < image_.size(); ++i) { |
| 45 | 8240 | result_[i] = static_cast<uint8_t>(((image_[i] - min_val) * 255) / range); | |
| 46 | } | ||
| 47 | |||
| 48 | return true; | ||
| 49 | } | ||
| 50 | |||
| 51 | 80 | bool DoroginVContrastEnhancementSEQ::PostProcessingImpl() { | |
| 52 | 80 | GetOutput() = result_; | |
| 53 | 80 | return true; | |
| 54 | } | ||
| 55 | |||
| 56 | } // namespace dorogin_v_contrast_enhancement | ||
| 57 |