GCC Code Coverage Report


Directory: ./
File: tasks/otcheskov_s_contrast_lin_stretch/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 5 5 100.0%
Branches: 10 12 83.3%

Line Branch Exec Source
1 #include "otcheskov_s_contrast_lin_stretch/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cstddef>
5 #include <cstdint>
6 #include <vector>
7
8 #include "otcheskov_s_contrast_lin_stretch/common/include/common.hpp"
9
10 namespace otcheskov_s_contrast_lin_stretch {
11
12
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 OtcheskovSContrastLinStretchSEQ::OtcheskovSContrastLinStretchSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 GetInput() = in;
15 GetOutput().clear();
16 72 }
17
18 72 bool OtcheskovSContrastLinStretchSEQ::ValidationImpl() {
19 72 return !GetInput().empty();
20 }
21
22 72 bool OtcheskovSContrastLinStretchSEQ::PreProcessingImpl() {
23 72 GetOutput().resize(GetInput().size());
24 72 return GetOutput().size() == GetInput().size();
25 }
26
27
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 bool OtcheskovSContrastLinStretchSEQ::RunImpl() {
28
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 if (GetInput().empty()) {
29 return false;
30 }
31
32 const InType &input = GetInput();
33 OutType &output = GetOutput();
34
35 auto [min_it, max_it] = std::ranges::minmax_element(input);
36 64 uint8_t min_val = *min_it;
37 64 uint8_t max_val = *max_it;
38
39
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 40 times.
64 if (min_val == max_val) {
40 24 output = input;
41 24 return true;
42 }
43
44 40 const int min_i = static_cast<int>(min_val);
45 40 const int max_i = static_cast<int>(max_val);
46 40 const int range = max_i - min_i;
47
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10602024 times.
10602064 for (size_t i = 0; i < input.size(); ++i) {
48 10602024 int pixel = static_cast<int>(input[i]);
49 10602024 int value = (pixel - min_i) * 255 / (range);
50
51 value = std::clamp(value, 0, 255);
52
53 10602024 output[i] = static_cast<uint8_t>(value);
54 }
55
56 return true;
57 }
58
59 72 bool OtcheskovSContrastLinStretchSEQ::PostProcessingImpl() {
60 72 return true;
61 }
62
63 } // namespace otcheskov_s_contrast_lin_stretch
64