GCC Code Coverage Report


Directory: ./
File: tasks/chaschin_vladimir_linear_image_filtration_seq/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 0 34 0.0%
Functions: 0 7 0.0%
Branches: 0 18 0.0%

Line Branch Exec Source
1 #include "chaschin_vladimir_linear_image_filtration_seq/seq/include/ops_seq.hpp"
2
3 #include <utility>
4 #include <vector>
5
6 #include "chaschin_vladimir_linear_image_filtration_seq/common/include/common.hpp"
7 namespace chaschin_v_linear_image_filtration_seq {
8
9 ChaschinVLinearFiltrationSEQ::ChaschinVLinearFiltrationSEQ(const InType &in) {
10 SetTypeOfTask(GetStaticTypeOfTask());
11 auto in_copy = in;
12 GetInput() = std::move(in_copy);
13 this->GetOutput().clear();
14 }
15
16 bool ChaschinVLinearFiltrationSEQ::ValidationImpl() {
17 const auto &in = GetInput();
18
19 const auto &image = std::get<0>(in);
20
21 return !image.empty();
22 }
23
24 bool ChaschinVLinearFiltrationSEQ::PreProcessingImpl() {
25 return true;
26 }
27
28 inline float HorizontalFilterAt(const std::vector<float> &img, int n, int x, int y) {
29 const int idx = (y * n) + x;
30
31 if (x == 0) {
32 return ((2.F * img[idx]) + img[idx + 1]) / 3.F;
33 }
34
35 if (x == n - 1) {
36 return (img[idx - 1] + (2.F * img[idx])) / 3.F;
37 }
38
39 return (img[idx - 1] + (2.F * img[idx]) + img[idx + 1]) / 4.F;
40 }
41 inline float VerticalFilterAt(const std::vector<float> &temp, int n, int m, int x, int y) {
42 const int idx = (y * n) + x;
43
44 if (y == 0) {
45 return ((2.F * temp[idx]) + temp[idx + n]) / 3.F;
46 }
47
48 if (y == m - 1) {
49 return (temp[idx - n] + (2.F * temp[idx])) / 3.F;
50 }
51
52 return (temp[idx - n] + (2.F * temp[idx]) + temp[idx + n]) / 4.F;
53 }
54
55 bool ChaschinVLinearFiltrationSEQ::RunImpl() {
56 const auto &in = GetInput();
57 const auto &image = std::get<0>(in);
58 int n = std::get<1>(in); // width
59 int m = std::get<2>(in); // height
60
61 auto &out = GetOutput();
62 out.resize(static_cast<std::vector<float>::size_type>(n) * static_cast<std::vector<float>::size_type>(m));
63
64 std::vector<float> temp(static_cast<std::vector<float>::size_type>(n) *
65 static_cast<std::vector<float>::size_type>(m));
66
67 // ---------- горизонтальная фильтрация ----------
68 for (int yi = 0; yi < m; ++yi) {
69 for (int xf = 0; xf < n; ++xf) {
70 temp[(yi * n) + xf] = HorizontalFilterAt(image, n, xf, yi);
71 }
72 }
73
74 for (int yi = 0; yi < m; ++yi) {
75 for (int xy = 0; xy < n; ++xy) {
76 out[(yi * n) + xy] = VerticalFilterAt(temp, n, m, xy, yi);
77 }
78 }
79
80 return true;
81 }
82
83 bool ChaschinVLinearFiltrationSEQ::PostProcessingImpl() {
84 return true;
85 }
86
87 } // namespace chaschin_v_linear_image_filtration_seq
88