GCC Code Coverage Report


Directory: ./
File: tasks/belov_e_sobel/seq/src/ops_seq.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 5 5 100.0%
Branches: 13 22 59.1%

Line Branch Exec Source
1 #include "belov_e_sobel/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <cstdint>
7 #include <vector>
8
9 #include "belov_e_sobel/common/include/common.hpp"
10
11 namespace belov_e_sobel {
12
13
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 BelovESobelSEQ::BelovESobelSEQ(const InType &in) {
14 SetTypeOfTask(GetStaticTypeOfTask());
15 GetInput() = in;
16 GetOutput() = in;
17 16 }
18
19
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 bool BelovESobelSEQ::ValidationImpl() {
20
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 return !std::get<0>(GetInput()).empty() && (std::get<1>(GetInput()) > 0) && (std::get<2>(GetInput()) > 0);
21 }
22
23 16 bool BelovESobelSEQ::PreProcessingImpl() {
24 16 return true;
25 }
26
27 16 bool BelovESobelSEQ::RunImpl() {
28 const std::vector<uint8_t> &input = std::get<0>(GetInput());
29 std::vector<uint8_t> &output = std::get<0>(GetOutput());
30 16 int width = std::get<1>(GetInput());
31 16 int height = std::get<2>(GetInput());
32
33 auto get_px = [&](int col, int row) -> float {
34 6628064 int clamped_x = std::clamp(col, 0, width - 1);
35 6628064 int clamped_y = std::clamp(row, 0, height - 1);
36 6628064 return static_cast<float>(input[(static_cast<std::size_t>(clamped_y) * width) + clamped_x]);
37 };
38
39
2/2
✓ Branch 0 taken 9592 times.
✓ Branch 1 taken 16 times.
9608 for (int row = 0; row < height; ++row) {
40
2/2
✓ Branch 0 taken 6628064 times.
✓ Branch 1 taken 9592 times.
6637656 for (int col = 0; col < width; ++col) {
41 // ядро Gx (горизонтальное)
42 6628064 float gx = (-1 * get_px(col - 1, row - 1)) + (1 * get_px(col + 1, row - 1)) + (-2 * get_px(col - 1, row)) +
43 6628064 (2 * get_px(col + 1, row)) + (-1 * get_px(col - 1, row + 1)) + (1 * get_px(col + 1, row + 1));
44 // ядро Gy (вертикальное)
45 6628064 float gy = (-1 * get_px(col - 1, row - 1)) - (2 * get_px(col, row - 1)) - (1 * get_px(col + 1, row - 1)) +
46 6628064 (1 * get_px(col - 1, row + 1)) + (2 * get_px(col, row + 1)) + (1 * get_px(col + 1, row + 1));
47 // Результат
48 6628064 float magnitude = std::sqrt((gx * gx) + (gy * gy));
49 6628064 output[(static_cast<std::size_t>(row) * width) + col] = static_cast<uint8_t>(std::min(255.0F, magnitude));
50 }
51 }
52
53 16 return true;
54 }
55
56
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 bool BelovESobelSEQ::PostProcessingImpl() {
57
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 return !std::get<0>(GetOutput()).empty() && (std::get<1>(GetOutput()) > 0) && (std::get<2>(GetOutput()) > 0);
58 }
59
60 } // namespace belov_e_sobel
61