3 #include <isce3/core/EMatrix.h>
20 template<
typename EigenT1,
typename EigenT2>
21 auto multilookWeightedAvg(
const EigenT1& input,
int row_looks,
int col_looks,
22 const EigenT2& weights)
25 const auto nrows = input.rows() / row_looks;
26 const auto ncols = input.cols() / col_looks;
28 using value_type =
typename EigenT1::value_type;
29 isce3::core::EArray2D<value_type> output(nrows, ncols);
31 #pragma omp parallel for collapse(2)
32 for (
int row = 0; row < nrows; ++row) {
33 for (
int col = 0; col < ncols; ++col) {
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);
40 output(row, col) = (cells * wgts).sum() / wgts.sum();
56 template<
typename EigenType>
57 auto multilookSummed(
const EigenType& input,
int row_looks,
int col_looks)
60 const auto nrows = input.rows() / row_looks;
61 const auto ncols = input.cols() / col_looks;
63 using value_type =
typename EigenType::value_type;
64 isce3::core::EArray2D<value_type> output(nrows, ncols);
66 #pragma omp parallel for collapse(2)
67 for (
int row = 0; row < nrows; ++row) {
68 for (
int col = 0; col < ncols; ++col) {
70 output(row, col) = input.block(row * row_looks, col * col_looks,
88 template<
typename EigenType>
89 auto multilookAveraged(
const EigenType& input,
int row_looks,
int col_looks)
92 const auto nrows = input.rows() / row_looks;
93 const auto ncols = input.cols() / col_looks;
95 using value_type =
typename EigenType::value_type;
96 isce3::core::EArray2D<value_type> output(nrows, ncols);
98 #pragma omp parallel for collapse(2)
99 for (
int row = 0; row < nrows; ++row) {
100 for (
int col = 0; col < ncols; ++col) {
102 output(row, col) = input.block(row * row_looks, col * col_looks,
103 row_looks, col_looks)
125 template<
typename EigenInput>
126 auto multilookNoData(
const EigenInput& input,
int row_looks,
int col_looks,
127 const typename EigenInput::value_type nodata)
130 auto upcast_bool = [](
const bool b) {
131 typename EigenInput::value_type ret = b ? 1 : 0;
135 auto weights = (input != nodata).unaryExpr(upcast_bool);
137 return multilookWeightedAvg(input, row_looks, col_looks, weights);
150 template<
typename EigenInput>
151 auto multilookPow(
const EigenInput& input,
int row_looks,
int col_looks,
155 return multilookAveraged(input.abs().pow(exponent), row_looks, col_looks);