GCC Code Coverage Report


Directory: ./
File: tasks/fatehov_k_gaussian/omp/src/ops_omp.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 30 30 100.0%
Functions: 5 5 100.0%
Branches: 12 18 66.7%

Line Branch Exec Source
1 #include "fatehov_k_gaussian/omp/include/ops_omp.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 12 times.
✗ Branch 2 not taken.
12 FatehovKGaussianOMP::FatehovKGaussianOMP(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 12 }
16
17 12 bool FatehovKGaussianOMP::ValidationImpl() {
18 const auto &input = GetInput();
19
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
12 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 12 times.
12 input.sigma > 0.0F;
21 }
22
23 12 bool FatehovKGaussianOMP::PreProcessingImpl() {
24 const auto &input = GetInput();
25 12 float sigma = input.sigma;
26
27 12 kernel_size_ = (2 * static_cast<int>(std::ceil(3.0F * sigma))) + 1;
28 12 kernel_.resize(static_cast<size_t>(kernel_size_) * kernel_size_);
29
30 12 int half = kernel_size_ / 2;
31 float sum = 0.0F;
32 12 float two_sigma_sq = 2.0F * sigma * sigma;
33
34
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 12 times.
96 for (int i = -half; i <= half; i++) {
35
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 84 times.
672 for (int j = -half; j <= half; j++) {
36 588 float val = std::exp(-(static_cast<float>((i * i) + (j * j))) / two_sigma_sq);
37 588 kernel_[((i + half) * kernel_size_) + (j + half)] = val;
38 588 sum += val;
39 }
40 }
41
42
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 12 times.
600 for (float &val : kernel_) {
43 588 val /= sum;
44 }
45
46 auto &output = GetOutput();
47 12 output = Image(input.image.width, input.image.height, input.image.channels);
48
49 12 return true;
50 }
51
52 12 bool FatehovKGaussianOMP::RunImpl() {
53 const auto &input = GetInput();
54 auto &output = GetOutput();
55 12 const int w = static_cast<int>(input.image.width);
56 12 const int h = static_cast<int>(input.image.height);
57 12 const int ch = static_cast<int>(input.image.channels);
58 12 const int half = kernel_size_ / 2;
59 const int kernel_size = kernel_size_;
60 12 const auto &kernel = kernel_;
61
62 12 #pragma omp parallel for default(none) shared(input, output, w, h, ch, half, kernel, kernel_size) schedule(static)
63 for (int y_coord = 0; y_coord < h; y_coord++) {
64 for (int x_coord = 0; x_coord < w; x_coord++) {
65 for (int c_coord = 0; c_coord < ch; c_coord++) {
66 float res = 0.0F;
67 for (int ky = -half; ky <= half; ky++) {
68 for (int kx = -half; kx <= half; kx++) {
69 int ny = std::clamp(y_coord + ky, 0, h - 1);
70 int nx = std::clamp(x_coord + kx, 0, w - 1);
71 float weight = kernel[((ky + half) * kernel_size) + (kx + half)];
72 res += static_cast<float>(input.image.data[((ny * w + nx) * ch) + c_coord]) * weight;
73 }
74 }
75 output.data[((y_coord * w + x_coord) * ch) + c_coord] = static_cast<uint8_t>(std::clamp(res, 0.0F, 255.0F));
76 }
77 }
78 }
79 12 return true;
80 }
81
82 12 bool FatehovKGaussianOMP::PostProcessingImpl() {
83 12 return true;
84 }
85
86 } // namespace fatehov_k_gaussian
87