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