| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "lukin_i_ench_contr_lin_hist/omp/include/ops_omp.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | #include "lukin_i_ench_contr_lin_hist/common/include/common.hpp" | ||
| 7 | |||
| 8 | namespace lukin_i_ench_contr_lin_hist { | ||
| 9 | |||
| 10 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | LukinITestTaskOMP::LukinITestTaskOMP(const InType &in) { |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | GetInput() = in; |
| 13 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | GetOutput() = OutType(GetInput().size()); |
| 14 | 16 | } | |
| 15 | |||
| 16 | 16 | bool LukinITestTaskOMP::ValidationImpl() { | |
| 17 | 16 | return !(GetInput().empty()); | |
| 18 | } | ||
| 19 | |||
| 20 | 16 | bool LukinITestTaskOMP::PreProcessingImpl() { | |
| 21 | 16 | return true; | |
| 22 | } | ||
| 23 | |||
| 24 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
|
16 | bool LukinITestTaskOMP::RunImpl() { |
| 25 | const auto &input = GetInput(); | ||
| 26 | auto &output = GetOutput(); | ||
| 27 | |||
| 28 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
|
16 | unsigned char min = 255; |
| 29 | unsigned char max = 0; | ||
| 30 | |||
| 31 | 16 | const int size = static_cast<int>(input.size()); | |
| 32 | |||
| 33 | 16 | #pragma omp parallel for default(none) shared(input, size) reduction(min : min) \ | |
| 34 | reduction(max : max) //(max : max) - оператор, потом указание переменной | ||
| 35 | for (int i = 0; i < size; i++) { | ||
| 36 | min = std::min(min, input[i]); | ||
| 37 | max = std::max(max, input[i]); | ||
| 38 | } | ||
| 39 | |||
| 40 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
|
16 | if (max == min) // Однотонное изображение |
| 41 | { | ||
| 42 | 4 | output = input; | |
| 43 | 4 | return true; | |
| 44 | } | ||
| 45 | |||
| 46 | 12 | float scale = 255.0F / static_cast<float>(max - min); | |
| 47 | |||
| 48 | 12 | #pragma omp parallel for default(none) shared(input, output, min, size, scale) | |
| 49 | for (int i = 0; i < size; i++) { // Линейное растяжение | ||
| 50 | output[i] = static_cast<unsigned char>(static_cast<float>(input[i] - min) * scale); | ||
| 51 | } | ||
| 52 | |||
| 53 | 12 | return true; | |
| 54 | } | ||
| 55 | |||
| 56 | 16 | bool LukinITestTaskOMP::PostProcessingImpl() { | |
| 57 | 16 | return true; | |
| 58 | } | ||
| 59 | |||
| 60 | } // namespace lukin_i_ench_contr_lin_hist | ||
| 61 |