| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "rychkova_gauss/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <cstdint> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "rychkova_gauss/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace rychkova_gauss { | ||
| 11 | |||
| 12 | namespace { | ||
| 13 | int Mirror(int x, int xmin, int xmax) { | ||
| 14 | 113698944 | if (x < xmin) { | |
| 15 | return 1; | ||
| 16 | } | ||
| 17 |
4/4✓ Branch 0 taken 62112 times.
✓ Branch 1 taken 56725248 times.
✓ Branch 2 taken 58248 times.
✓ Branch 3 taken 56732976 times.
|
113578584 | if (x >= xmax) { |
| 18 | 120360 | return xmax - 1; | |
| 19 | } | ||
| 20 | return x; | ||
| 21 | }; | ||
| 22 | |||
| 23 | 6316608 | Pixel ComputePixel(const Image &image, std::size_t x, std::size_t y, std::size_t width, std::size_t height) { | |
| 24 | Pixel result = {.R = 0, .G = 0, .B = 0}; | ||
| 25 |
2/2✓ Branch 0 taken 18949824 times.
✓ Branch 1 taken 6316608 times.
|
25266432 | for (int shift_x = -1; shift_x < 2; shift_x++) { |
| 26 |
2/2✓ Branch 0 taken 56849472 times.
✓ Branch 1 taken 18949824 times.
|
75799296 | for (int shift_y = -1; shift_y < 2; shift_y++) { |
| 27 |
2/2✓ Branch 0 taken 56787360 times.
✓ Branch 1 taken 62112 times.
|
56849472 | int xn = Mirror(static_cast<int>(x) + shift_x, 0, static_cast<int>(width)); |
| 28 |
2/2✓ Branch 0 taken 56791224 times.
✓ Branch 1 taken 58248 times.
|
56849472 | int yn = Mirror(static_cast<int>(y) + shift_y, 0, static_cast<int>(height)); |
| 29 | 56849472 | auto current = image[yn][xn]; | |
| 30 | 56849472 | result.R += static_cast<uint8_t>(static_cast<double>(current.R) * kKernel[shift_x + 1][shift_y + 1]); | |
| 31 | 56849472 | result.G += static_cast<uint8_t>(static_cast<double>(current.G) * kKernel[shift_x + 1][shift_y + 1]); | |
| 32 | 56849472 | result.B += static_cast<uint8_t>(static_cast<double>(current.B) * kKernel[shift_x + 1][shift_y + 1]); | |
| 33 | } | ||
| 34 | } | ||
| 35 | 6316608 | return result; | |
| 36 | } | ||
| 37 | } // namespace | ||
| 38 | |||
| 39 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | RychkovaGaussSEQ::RychkovaGaussSEQ(const InType &in) { |
| 40 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 41 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | GetInput() = in; |
| 42 | GetOutput() = {}; // cписок инициализации - пустой вектор - каждый вложенный вектор и пиксели внутри по умолчанию | ||
| 43 | 64 | } | |
| 44 | |||
| 45 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | bool RychkovaGaussSEQ::ValidationImpl() { |
| 46 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | if (GetInput().empty()) { |
| 47 | return false; | ||
| 48 | } | ||
| 49 | const auto len = GetInput()[0].size(); | ||
| 50 | return std::ranges::all_of(GetInput(), [len](const auto &row) { return row.size() == len; }); | ||
| 51 | } | ||
| 52 | |||
| 53 | 64 | bool RychkovaGaussSEQ::PreProcessingImpl() { | |
| 54 | 64 | return true; | |
| 55 | } | ||
| 56 | |||
| 57 | 64 | bool RychkovaGaussSEQ::RunImpl() { | |
| 58 | const auto &image = GetInput(); // сохран.изоб. | ||
| 59 | const auto width = image[0].size(); | ||
| 60 | const auto height = image.size(); // сайз от имаге хранит количествo строк | ||
| 61 |
1/2✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
|
64 | GetOutput() = Image(height, std::vector<Pixel>(width, Pixel(0, 0, 0))); |
| 62 |
2/2✓ Branch 0 taken 20704 times.
✓ Branch 1 taken 64 times.
|
20768 | for (std::size_t j = 0; j < height; j++) { |
| 63 |
2/2✓ Branch 0 taken 6316608 times.
✓ Branch 1 taken 20704 times.
|
6337312 | for (std::size_t i = 0; i < width; i++) { |
| 64 | 6316608 | GetOutput()[j][i] = ComputePixel(image, i, j, width, height); | |
| 65 | } | ||
| 66 | } | ||
| 67 | 64 | return true; | |
| 68 | } | ||
| 69 | |||
| 70 | 64 | bool RychkovaGaussSEQ::PostProcessingImpl() { | |
| 71 | 64 | return true; | |
| 72 | } | ||
| 73 | |||
| 74 | } // namespace rychkova_gauss | ||
| 75 |