| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "shakirova_e_sobel_edge_detection/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <array> | ||
| 5 | #include <cmath> | ||
| 6 | #include <cstddef> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "shakirova_e_sobel_edge_detection/common/include/common.hpp" | ||
| 10 | |||
| 11 | namespace shakirova_e_sobel_edge_detection { | ||
| 12 | |||
| 13 |
1/2✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
|
48 | ShakirovaESobelEdgeDetectionSEQ::ShakirovaESobelEdgeDetectionSEQ(const InType &in) { |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 | GetInput() = in; | ||
| 16 | GetOutput().clear(); | ||
| 17 | 48 | } | |
| 18 | |||
| 19 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | bool ShakirovaESobelEdgeDetectionSEQ::ValidationImpl() { |
| 20 | 48 | return GetInput().IsValid(); | |
| 21 | } | ||
| 22 | |||
| 23 | 48 | bool ShakirovaESobelEdgeDetectionSEQ::PreProcessingImpl() { | |
| 24 | const auto &img = GetInput(); | ||
| 25 | 48 | width_ = img.width; | |
| 26 | 48 | height_ = img.height; | |
| 27 | 48 | input_ = img.pixels; | |
| 28 | |||
| 29 | 48 | GetOutput().assign(static_cast<size_t>(width_) * static_cast<size_t>(height_), 0); | |
| 30 | 48 | return true; | |
| 31 | } | ||
| 32 | |||
| 33 | 48 | bool ShakirovaESobelEdgeDetectionSEQ::RunImpl() { | |
| 34 | 48 | const std::array<std::array<int, 3>, 3> k_gx = {{{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}}; | |
| 35 | 48 | const std::array<std::array<int, 3>, 3> k_gy = {{{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}}}; | |
| 36 | |||
| 37 | auto &out = GetOutput(); | ||
| 38 | |||
| 39 |
2/2✓ Branch 0 taken 12488 times.
✓ Branch 1 taken 48 times.
|
12536 | for (int row = 1; row < height_ - 1; ++row) { |
| 40 |
2/2✓ Branch 0 taken 6516712 times.
✓ Branch 1 taken 12488 times.
|
6529200 | for (int col = 1; col < width_ - 1; ++col) { |
| 41 | int gx = 0; | ||
| 42 | int gy = 0; | ||
| 43 | |||
| 44 |
2/2✓ Branch 0 taken 19550136 times.
✓ Branch 1 taken 6516712 times.
|
26066848 | for (int ky = -1; ky <= 1; ++ky) { |
| 45 |
2/2✓ Branch 0 taken 58650408 times.
✓ Branch 1 taken 19550136 times.
|
78200544 | for (int kx = -1; kx <= 1; ++kx) { |
| 46 | 58650408 | const int pixel = input_[((row + ky) * width_) + (col + kx)]; | |
| 47 | 58650408 | const auto ky_idx = static_cast<size_t>(ky) + 1; | |
| 48 | 58650408 | const auto kx_idx = static_cast<size_t>(kx) + 1; | |
| 49 | 58650408 | gx += pixel * k_gx.at(ky_idx).at(kx_idx); | |
| 50 | 58650408 | gy += pixel * k_gy.at(ky_idx).at(kx_idx); | |
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | 6516712 | const int magnitude = static_cast<int>(std::sqrt(static_cast<double>((gx * gx) + (gy * gy)))); | |
| 55 | 6516712 | out[(row * width_) + col] = std::clamp(magnitude, 0, 255); | |
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | 48 | return true; | |
| 60 | } | ||
| 61 | |||
| 62 | 48 | bool ShakirovaESobelEdgeDetectionSEQ::PostProcessingImpl() { | |
| 63 | 48 | return true; | |
| 64 | } | ||
| 65 | |||
| 66 | } // namespace shakirova_e_sobel_edge_detection | ||
| 67 |