| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "baldin_a_gauss_filter/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <array> | ||
| 5 | #include <cstddef> | ||
| 6 | #include <cstdint> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "baldin_a_gauss_filter/common/include/common.hpp" | ||
| 10 | |||
| 11 | namespace baldin_a_gauss_filter { | ||
| 12 | |||
| 13 |
1/2✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
|
120 | BaldinAGaussFilterSEQ::BaldinAGaussFilterSEQ(const InType &in) { |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 | GetInput() = in; | ||
| 16 | 120 | } | |
| 17 | |||
| 18 |
1/2✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
|
120 | bool BaldinAGaussFilterSEQ::ValidationImpl() { |
| 19 | const auto &im = GetInput(); | ||
| 20 | 120 | bool size_match = (im.pixels.size() == (static_cast<size_t>(im.width) * im.height * im.channels)); | |
| 21 |
4/8✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
|
120 | return (im.width > 0 && im.height > 0 && im.channels > 0 && size_match); |
| 22 | } | ||
| 23 | |||
| 24 | 120 | bool BaldinAGaussFilterSEQ::PreProcessingImpl() { | |
| 25 | 120 | return true; | |
| 26 | } | ||
| 27 | |||
| 28 | 120 | bool BaldinAGaussFilterSEQ::RunImpl() { | |
| 29 | ImageData &input = GetInput(); | ||
| 30 | ImageData res = input; | ||
| 31 | 120 | int w = input.width; | |
| 32 | 120 | int h = input.height; | |
| 33 | 120 | int c = input.channels; | |
| 34 | |||
| 35 | 120 | constexpr std::array<int, 9> kKernel = {1, 2, 1, 2, 4, 2, 1, 2, 1}; | |
| 36 | |||
| 37 |
2/2✓ Branch 0 taken 7624 times.
✓ Branch 1 taken 120 times.
|
7744 | for (int row = 0; row < h; row++) { |
| 38 |
2/2✓ Branch 0 taken 582344 times.
✓ Branch 1 taken 7624 times.
|
589968 | for (int col = 0; col < w; col++) { |
| 39 |
2/2✓ Branch 0 taken 1394104 times.
✓ Branch 1 taken 582344 times.
|
1976448 | for (int ch = 0; ch < c; ch++) { |
| 40 | int sum = 0; | ||
| 41 |
2/2✓ Branch 0 taken 4182312 times.
✓ Branch 1 taken 1394104 times.
|
5576416 | for (int dy = -1; dy <= 1; dy++) { |
| 42 |
2/2✓ Branch 0 taken 12546936 times.
✓ Branch 1 taken 4182312 times.
|
16729248 | for (int dx = -1; dx <= 1; dx++) { |
| 43 | 12546936 | int ny = std::clamp(row + dy, 0, h - 1); | |
| 44 | 12546936 | int nx = std::clamp(col + dx, 0, w - 1); | |
| 45 | |||
| 46 | 12546936 | int pixel_val = input.pixels[((ny * w + nx) * c) + ch]; | |
| 47 | 12546936 | int kernel_val = kKernel.at((static_cast<size_t>(dy + 1) * 3) + (dx + 1)); | |
| 48 | 12546936 | sum += pixel_val * kernel_val; | |
| 49 | } | ||
| 50 | } | ||
| 51 | 1394104 | res.pixels[((row * w + col) * c) + ch] = static_cast<uint8_t>(sum / 16); | |
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | GetOutput() = res; | ||
| 57 | 120 | return true; | |
| 58 | } | ||
| 59 | |||
| 60 | 120 | bool BaldinAGaussFilterSEQ::PostProcessingImpl() { | |
| 61 | 120 | return true; | |
| 62 | } | ||
| 63 | |||
| 64 | } // namespace baldin_a_gauss_filter | ||
| 65 |