@Test public void testMultilook() throws Exception { int[] mlookFactorAz = new int[]{1, 2, 5, 5}; int[] mlookFactorRg = new int[]{2, 2, 1, 5}; for (int i = 0; i < mlookFactorAz.length; i++) { int facAz = mlookFactorAz[i]; int facRg = mlookFactorRg[i]; ComplexDoubleMatrix cplxData_mlook_ACTUAL = SarUtils.multilook(cplxData, facAz, facRg); String fileName = testDataLocation + "testdata_mlook_" + facAz + "_" + facRg + ".cr8"; ComplexDoubleMatrix cplxData_mlook_EXPECTED = readCplxDoubleData(fileName, cplxData_mlook_ACTUAL.rows, cplxData_mlook_ACTUAL.columns, ByteOrder.LITTLE_ENDIAN); Assert.assertArrayEquals(cplxData_mlook_EXPECTED.toDoubleArray(), cplxData_mlook_ACTUAL.toDoubleArray(), DELTA_08); } }
public static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn) { if (factorRow == 1 && factorColumn == 1) { return inputMatrix; } logger.debug("multilook input [inputMatrix] size: " + inputMatrix.length + " lines: " + inputMatrix.rows + " pixels: " + inputMatrix.columns); if (inputMatrix.rows / factorRow == 0 || inputMatrix.columns / factorColumn == 0) { logger.debug("Multilooking was not necessary for this inputMatrix: inputMatrix.rows < mlR or buffer.columns < mlC"); return inputMatrix; } ComplexDouble sum; final ComplexDouble factorLP = new ComplexDouble(factorRow * factorColumn); ComplexDoubleMatrix outputMatrix = new ComplexDoubleMatrix(inputMatrix.rows / factorRow, inputMatrix.columns / factorColumn); for (int i = 0; i < outputMatrix.rows; i++) { for (int j = 0; j < outputMatrix.columns; j++) { sum = new ComplexDouble(0); for (int k = i * factorRow; k < (i + 1) * factorRow; k++) { for (int l = j * factorColumn; l < (j + 1) * factorColumn; l++) { sum.addi(inputMatrix.get(k, l)); } } outputMatrix.put(i, j, sum.div(factorLP)); } } return outputMatrix; }
SarUtils { public static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn) { if (factorRow == 1 && factorColumn == 1) { return inputMatrix; } logger.debug("multilook input [inputMatrix] size: " + inputMatrix.length + " lines: " + inputMatrix.rows + " pixels: " + inputMatrix.columns); if (inputMatrix.rows / factorRow == 0 || inputMatrix.columns / factorColumn == 0) { logger.debug("Multilooking was not necessary for this inputMatrix: inputMatrix.rows < mlR or buffer.columns < mlC"); return inputMatrix; } ComplexDouble sum; final ComplexDouble factorLP = new ComplexDouble(factorRow * factorColumn); ComplexDoubleMatrix outputMatrix = new ComplexDoubleMatrix(inputMatrix.rows / factorRow, inputMatrix.columns / factorColumn); for (int i = 0; i < outputMatrix.rows; i++) { for (int j = 0; j < outputMatrix.columns; j++) { sum = new ComplexDouble(0); for (int k = i * factorRow; k < (i + 1) * factorRow; k++) { for (int l = j * factorColumn; l < (j + 1) * factorColumn; l++) { sum.addi(inputMatrix.get(k, l)); } } outputMatrix.put(i, j, sum.div(factorLP)); } } return outputMatrix; } }
SarUtils { public static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn) { if (factorRow == 1 && factorColumn == 1) { return inputMatrix; } logger.debug("multilook input [inputMatrix] size: " + inputMatrix.length + " lines: " + inputMatrix.rows + " pixels: " + inputMatrix.columns); if (inputMatrix.rows / factorRow == 0 || inputMatrix.columns / factorColumn == 0) { logger.debug("Multilooking was not necessary for this inputMatrix: inputMatrix.rows < mlR or buffer.columns < mlC"); return inputMatrix; } ComplexDouble sum; final ComplexDouble factorLP = new ComplexDouble(factorRow * factorColumn); ComplexDoubleMatrix outputMatrix = new ComplexDoubleMatrix(inputMatrix.rows / factorRow, inputMatrix.columns / factorColumn); for (int i = 0; i < outputMatrix.rows; i++) { for (int j = 0; j < outputMatrix.columns; j++) { sum = new ComplexDouble(0); for (int k = i * factorRow; k < (i + 1) * factorRow; k++) { for (int l = j * factorColumn; l < (j + 1) * factorColumn; l++) { sum.addi(inputMatrix.get(k, l)); } } outputMatrix.put(i, j, sum.div(factorLP)); } } return outputMatrix; }  }
SarUtils { public static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn) { if (factorRow == 1 && factorColumn == 1) { return inputMatrix; } logger.debug("multilook input [inputMatrix] size: " + inputMatrix.length + " lines: " + inputMatrix.rows + " pixels: " + inputMatrix.columns); if (inputMatrix.rows / factorRow == 0 || inputMatrix.columns / factorColumn == 0) { logger.debug("Multilooking was not necessary for this inputMatrix: inputMatrix.rows < mlR or buffer.columns < mlC"); return inputMatrix; } ComplexDouble sum; final ComplexDouble factorLP = new ComplexDouble(factorRow * factorColumn); ComplexDoubleMatrix outputMatrix = new ComplexDoubleMatrix(inputMatrix.rows / factorRow, inputMatrix.columns / factorColumn); for (int i = 0; i < outputMatrix.rows; i++) { for (int j = 0; j < outputMatrix.columns; j++) { sum = new ComplexDouble(0); for (int k = i * factorRow; k < (i + 1) * factorRow; k++) { for (int l = j * factorColumn; l < (j + 1) * factorColumn; l++) { sum.addi(inputMatrix.get(k, l)); } } outputMatrix.put(i, j, sum.div(factorLP)); } } return outputMatrix; }  static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol); static DoubleMatrix intensity(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix magnitude(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix angle(final ComplexDoubleMatrix cplxData); @Deprecated static DoubleMatrix coherence(final ComplexDoubleMatrix inputMatrix, final ComplexDoubleMatrix normsMatrix, final int winL, final int winP); static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP); static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static void computeIfg_inplace(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData,
                                                 final int ovsFactorAz, final int ovsFactorRg); }
SarUtils { public static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn) { if (factorRow == 1 && factorColumn == 1) { return inputMatrix; } logger.debug("multilook input [inputMatrix] size: " + inputMatrix.length + " lines: " + inputMatrix.rows + " pixels: " + inputMatrix.columns); if (inputMatrix.rows / factorRow == 0 || inputMatrix.columns / factorColumn == 0) { logger.debug("Multilooking was not necessary for this inputMatrix: inputMatrix.rows < mlR or buffer.columns < mlC"); return inputMatrix; } ComplexDouble sum; final ComplexDouble factorLP = new ComplexDouble(factorRow * factorColumn); ComplexDoubleMatrix outputMatrix = new ComplexDoubleMatrix(inputMatrix.rows / factorRow, inputMatrix.columns / factorColumn); for (int i = 0; i < outputMatrix.rows; i++) { for (int j = 0; j < outputMatrix.columns; j++) { sum = new ComplexDouble(0); for (int k = i * factorRow; k < (i + 1) * factorRow; k++) { for (int l = j * factorColumn; l < (j + 1) * factorColumn; l++) { sum.addi(inputMatrix.get(k, l)); } } outputMatrix.put(i, j, sum.div(factorLP)); } } return outputMatrix; }  static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol); static DoubleMatrix intensity(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix magnitude(final ComplexDoubleMatrix inputMatrix); static DoubleMatrix angle(final ComplexDoubleMatrix cplxData); @Deprecated static DoubleMatrix coherence(final ComplexDoubleMatrix inputMatrix, final ComplexDoubleMatrix normsMatrix, final int winL, final int winP); static DoubleMatrix coherence2(final ComplexDoubleMatrix input, final ComplexDoubleMatrix norms, final int winL, final int winP); static ComplexDoubleMatrix multilook(final ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorColumn); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static void computeIfg_inplace(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData); static ComplexDoubleMatrix computeIfg(final ComplexDoubleMatrix masterData, final ComplexDoubleMatrix slaveData,
                                                 final int ovsFactorAz, final int ovsFactorRg);  }