GCC Code Coverage Report


Directory: ./
File: tasks/batkov_f_contrast_enh_lin_hist_stretch/seq/src/ops_seq.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 5 5 100.0%
Branches: 6 10 60.0%

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