GCC Code Coverage Report


Directory: ./
File: tasks/fatehov_k_gaussian/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 5 5 100.0%
Branches: 22 28 78.6%

Line Branch Exec Source
1 #include "fatehov_k_gaussian/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <cstdint>
7
8 #include "fatehov_k_gaussian/common/include/common.hpp"
9
10 namespace fatehov_k_gaussian {
11
12
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 FatehovKGaussianSEQ::FatehovKGaussianSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 24 }
16
17 24 bool FatehovKGaussianSEQ::ValidationImpl() {
18 const auto &input = GetInput();
19
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 24 times.
24 return input.image.width > 0 && input.image.height > 0 && input.image.channels > 0 && !input.image.data.empty() &&
20
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 input.sigma > 0.0F;
21 }
22
23 24 bool FatehovKGaussianSEQ::PreProcessingImpl() {
24 const auto &input = GetInput();
25 24 float sigma = input.sigma;
26
27 24 kernel_size_ = (2 * static_cast<int>(std::ceil(3.0F * sigma))) + 1;
28 24 kernel_.resize(static_cast<size_t>(kernel_size_) * kernel_size_);
29
30 24 int half = kernel_size_ / 2;
31 float sum = 0.0F;
32 24 float two_sigma_sq = 2.0F * sigma * sigma;
33
34
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for (int i = -half; i <= half; i++) {
35
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 for (int j = -half; j <= half; j++) {
36 1176 float val = std::exp(-(static_cast<float>((i * i) + (j * j))) / two_sigma_sq);
37 1176 kernel_[((i + half) * kernel_size_) + (j + half)] = val;
38 1176 sum += val;
39 }
40 }
41
42
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 24 times.
1200 for (float &val : kernel_) {
43 1176 val /= sum;
44 }
45
46 auto &output = GetOutput();
47 24 output = Image(input.image.width, input.image.height, input.image.channels);
48
49 24 return true;
50 }
51
52 24 bool FatehovKGaussianSEQ::RunImpl() {
53 const auto &input = GetInput();
54 auto &output = GetOutput();
55 24 const int w = static_cast<int>(input.image.width);
56 24 const int h = static_cast<int>(input.image.height);
57 24 const int ch = static_cast<int>(input.image.channels);
58 24 const int half = kernel_size_ / 2;
59
60
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 24 times.
384 for (int y_coord = 0; y_coord < h; y_coord++) {
61
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 360 times.
6160 for (int x_coord = 0; x_coord < w; x_coord++) {
62
2/2
✓ Branch 0 taken 17400 times.
✓ Branch 1 taken 5800 times.
23200 for (int c_coord = 0; c_coord < ch; c_coord++) {
63 17400 float res = 0.0F;
64
2/2
✓ Branch 0 taken 121800 times.
✓ Branch 1 taken 17400 times.
139200 for (int ky = -half; ky <= half; ky++) {
65
2/2
✓ Branch 0 taken 852600 times.
✓ Branch 1 taken 121800 times.
974400 for (int kx = -half; kx <= half; kx++) {
66 852600 int ny = std::clamp(y_coord + ky, 0, h - 1);
67 852600 int nx = std::clamp(x_coord + kx, 0, w - 1);
68
69 852600 float weight = kernel_[((ky + half) * kernel_size_) + (kx + half)];
70 852600 res += static_cast<float>(input.image.data[((ny * w + nx) * ch) + c_coord]) * weight;
71 }
72 }
73 17400 output.data[((y_coord * w + x_coord) * ch) + c_coord] = static_cast<uint8_t>(std::clamp(res, 0.0F, 255.0F));
74 }
75 }
76 }
77 24 return true;
78 }
79
80 24 bool FatehovKGaussianSEQ::PostProcessingImpl() {
81 24 return true;
82 }
83
84 } // namespace fatehov_k_gaussian
85