isce3 0.25.0
Loading...
Searching...
No Matches
multilook.h
1#pragma once
2
3#include <isce3/core/EMatrix.h>
4
5namespace isce3 {
6namespace signal {
7
21template<typename EigenT1, typename EigenT2>
22auto multilookWeightedAvg(const EigenT1& input, int row_looks, int col_looks,
23 const EigenT2& weights)
24{
25
26 const auto nrows = input.rows() / row_looks;
27 const auto ncols = input.cols() / col_looks;
28
29 using value_type = typename EigenT1::value_type;
30 isce3::core::EArray2D<value_type> output(nrows, ncols);
31
32 #pragma omp parallel for collapse(2)
33 for (int row = 0; row < nrows; ++row) {
34 for (int col = 0; col < ncols; ++col) {
35
36 const auto cells = input.block(row * row_looks, col * col_looks,
37 row_looks, col_looks);
38 const auto wgts = weights.block(row * row_looks, col * col_looks,
39 row_looks, col_looks);
40
41 output(row, col) = (cells * wgts).sum() / wgts.sum();
42 }
43 }
44
45 return output;
46}
47
57template<typename EigenType>
58auto multilookSummed(const EigenType& input, int row_looks, int col_looks)
59{
60
61 const auto nrows = input.rows() / row_looks;
62 const auto ncols = input.cols() / col_looks;
63
64 using value_type = typename EigenType::value_type;
65 isce3::core::EArray2D<value_type> output(nrows, ncols);
66
67 #pragma omp parallel for collapse(2)
68 for (int row = 0; row < nrows; ++row) {
69 for (int col = 0; col < ncols; ++col) {
70
71 output(row, col) = input.block(row * row_looks, col * col_looks,
72 row_looks, col_looks)
73 .sum();
74 }
75 }
76
77 return output;
78}
79
89template<typename EigenType>
90auto multilookAveraged(const EigenType& input, int row_looks, int col_looks)
91{
92
93 const auto nrows = input.rows() / row_looks;
94 const auto ncols = input.cols() / col_looks;
95
96 using value_type = typename EigenType::value_type;
97 isce3::core::EArray2D<value_type> output(nrows, ncols);
98
99 #pragma omp parallel for collapse(2)
100 for (int row = 0; row < nrows; ++row) {
101 for (int col = 0; col < ncols; ++col) {
102
103 output(row, col) = input.block(row * row_looks, col * col_looks,
104 row_looks, col_looks)
105 .mean();
106 }
107 }
108
109 return output;
110}
111
126template<typename EigenInput>
127auto multilookNoData(const EigenInput& input, int row_looks, int col_looks,
128 const typename EigenInput::value_type nodata)
129{
130
131 auto upcast_bool = [](const bool b) {
132 typename EigenInput::value_type ret = b ? 1 : 0;
133 return ret;
134 };
135
136 auto weights = (input != nodata).unaryExpr(upcast_bool);
137
138 return multilookWeightedAvg(input, row_looks, col_looks, weights);
139}
140
151template<typename EigenInput>
152auto multilookPow(const EigenInput& input, int row_looks, int col_looks,
153 const int exponent)
154{
155
156 return multilookAveraged(input.abs().pow(exponent), row_looks, col_looks);
157}
158
159} // namespace signal
160} // namespace isce3
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.