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

Generated for ISCE3.0 by doxygen 1.8.5.