| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "chaschin_vladimir_linear_image_filtration_seq/all/include/ops_all.hpp" | ||
| 2 | |||
| 3 | #include <omp.h> | ||
| 4 | #include <tbb/tbb.h> | ||
| 5 | |||
| 6 | #include <utility> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "chaschin_vladimir_linear_image_filtration_seq/common/include/common.hpp" | ||
| 10 | |||
| 11 | namespace chaschin_v_linear_image_filtration_all { | ||
| 12 | |||
| 13 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | ChaschinVLinearFiltrationALL::ChaschinVLinearFiltrationALL(const chaschin_v_linear_image_filtration_seq::InType &in) { |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 | auto in_copy = in; | ||
| 16 | GetInput() = std::move(in_copy); | ||
| 17 | this->GetOutput().clear(); | ||
| 18 | 10 | } | |
| 19 | |||
| 20 | 10 | bool ChaschinVLinearFiltrationALL::ValidationImpl() { | |
| 21 | const auto &in = GetInput(); | ||
| 22 | const auto &image = std::get<0>(in); | ||
| 23 | 10 | return !image.empty(); | |
| 24 | } | ||
| 25 | |||
| 26 | 10 | bool ChaschinVLinearFiltrationALL::PreProcessingImpl() { | |
| 27 | 10 | return true; | |
| 28 | } | ||
| 29 | |||
| 30 | 9920 | inline float HorizontalFilterAtALL(const std::vector<float> &img, int n, int x, int y) { | |
| 31 | 9920 | const int idx = (y * n) + x; | |
| 32 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 9680 times.
|
9920 | if (x == 0) { |
| 33 | 240 | return ((2.F * img[idx]) + img[idx + 1]) / 3.F; | |
| 34 | } | ||
| 35 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 9440 times.
|
9680 | if (x == n - 1) { |
| 36 | 240 | return (img[idx - 1] + (2.F * img[idx])) / 3.F; | |
| 37 | } | ||
| 38 | 9440 | return (img[idx - 1] + (2.F * img[idx]) + img[idx + 1]) / 4.F; | |
| 39 | } | ||
| 40 | |||
| 41 | 9920 | inline float VerticalFilterAtALL(const std::vector<float> &temp, int n, int m, int x, int y) { | |
| 42 | 9920 | const int idx = (y * n) + x; | |
| 43 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 9680 times.
|
9920 | if (y == 0) { |
| 44 | 240 | return ((2.F * temp[idx]) + temp[idx + n]) / 3.F; | |
| 45 | } | ||
| 46 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 9440 times.
|
9680 | if (y == m - 1) { |
| 47 | 240 | return (temp[idx - n] + (2.F * temp[idx])) / 3.F; | |
| 48 | } | ||
| 49 | 9440 | return (temp[idx - n] + (2.F * temp[idx]) + temp[idx + n]) / 4.F; | |
| 50 | } | ||
| 51 | |||
| 52 | 10 | bool ChaschinVLinearFiltrationALL::RunImpl() { | |
| 53 | const auto &in = GetInput(); | ||
| 54 | const auto &image = std::get<0>(in); | ||
| 55 | 10 | int n = std::get<1>(in); | |
| 56 | 10 | int m = std::get<2>(in); | |
| 57 | |||
| 58 | auto &out = GetOutput(); | ||
| 59 | 10 | out.resize(static_cast<std::vector<float>::size_type>(n) * static_cast<std::vector<float>::size_type>(m)); | |
| 60 | 10 | std::vector<float> temp(static_cast<std::vector<float>::size_type>(n) * | |
| 61 | 10 | static_cast<std::vector<float>::size_type>(m)); | |
| 62 | |||
| 63 |
1/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
250 | tbb::parallel_for(tbb::blocked_range<int>(0, m), [&](const tbb::blocked_range<int> &r) { |
| 64 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 240 times.
|
480 | for (int yi = r.begin(); yi != r.end(); ++yi) { |
| 65 |
2/2✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 240 times.
|
10160 | for (int xf = 0; xf < n; ++xf) { |
| 66 | 9920 | temp[(yi * n) + xf] = HorizontalFilterAtALL(image, n, xf, yi); | |
| 67 | } | ||
| 68 | } | ||
| 69 | 240 | }); | |
| 70 | |||
| 71 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | #pragma omp parallel for default(none) shared(m, n, temp, out) |
| 72 | for (int yi = 0; yi < m; ++yi) { | ||
| 73 | for (int xy = 0; xy < n; ++xy) { | ||
| 74 | out[(yi * n) + xy] = VerticalFilterAtALL(temp, n, m, xy, yi); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | 10 | return true; | |
| 79 | } | ||
| 80 | |||
| 81 | 10 | bool ChaschinVLinearFiltrationALL::PostProcessingImpl() { | |
| 82 | 10 | return true; | |
| 83 | } | ||
| 84 | |||
| 85 | } // namespace chaschin_v_linear_image_filtration_all | ||
| 86 |