@Test public void testOversample() throws Exception { int[] ovsmpFactorAz = new int[]{1, 2, 2, 3}; int[] ovsmpFactorRg = new int[]{2, 1, 2, 3}; for (int i = 0; i < ovsmpFactorAz.length; i++) { int facAz = ovsmpFactorAz[i]; int facRg = ovsmpFactorRg[i]; ComplexDoubleMatrix cplxData_ovsmp_ACTUAL = SarUtils.oversample(cplxData, facAz, facRg); String fileName = testDataLocation + "testdata_ovsmp_" + facAz + "_" + facRg + ".cr8"; ComplexDoubleMatrix cplxData_ovsmp_EXPECTED = readCplxDoubleData(fileName, cplxData_ovsmp_ACTUAL.rows, cplxData_ovsmp_ACTUAL.columns, ByteOrder.LITTLE_ENDIAN); Assert.assertArrayEquals(cplxData_ovsmp_EXPECTED.toDoubleArray(), cplxData_ovsmp_ACTUAL.toDoubleArray(), DELTA_08); } }
public static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol) throws IllegalArgumentException { final int l = inputMatrix.rows; final int p = inputMatrix.columns; final int halfL = l / 2; final int halfP = p / 2; final int L2 = factorRow * l; final int P2 = factorCol * p; if (inputMatrix.isVector()) { logger.error("oversample: only 2d matrices."); throw new IllegalArgumentException("oversample: only 2d matrices"); } if (!MathUtils.isPower2(l) && factorRow != 1) { logger.error("oversample: numlines != 2^n"); throw new IllegalArgumentException("oversample: numlines != 2^n"); } if (!MathUtils.isPower2(p) && factorCol != 1) { logger.error("oversample: numcols != 2^n"); throw new IllegalArgumentException("oversample: numcols != 2^n"); } if (factorRow == 1 && factorCol == 1) { logger.info("oversample: both azimuth and range oversampling factors equal to 1!"); logger.info("oversample: returning inputMatrix!"); return inputMatrix; } final ComplexDouble half = new ComplexDouble(0.5); ComplexDoubleMatrix returnMatrix = new ComplexDoubleMatrix(L2, P2); final Window winA1; final Window winA2; final Window winR2; ComplexDoubleMatrix tempMatrix; if (factorRow == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 2); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); winA1 = new Window(0, l - 1, 0, halfP); winA2 = new Window(0, l - 1, halfP, p - 1); winR2 = new Window(0, l - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 2); } else if (factorCol == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 1); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmul(half)); winA1 = new Window(0, halfL, 0, p - 1); winR2 = new Window(L2 - halfL, L2 - 1, 0, p - 1); winA2 = new Window(halfL, l - 1, 0, p - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 1); } else { Window winA3; Window winA4; Window winR3; Window winR4; tempMatrix = SpectralUtils.fft2D(inputMatrix); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmuli(half)); winA1 = new Window(0, halfL, 0, halfP); winA2 = new Window(0, halfL, halfP, p - 1); winA3 = new Window(halfL, l - 1, 0, halfP); winA4 = new Window(halfL, l - 1, halfP, p - 1); winR2 = new Window(0, halfL, P2 - halfP, P2 - 1); winR3 = new Window(L2 - halfL, L2 - 1, 0, halfP); winR4 = new Window(L2 - halfL, L2 - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); LinearAlgebraUtils.setdata(returnMatrix, winR3, tempMatrix, winA3); LinearAlgebraUtils.setdata(returnMatrix, winR4, tempMatrix, winA4); SpectralUtils.invfft2D_inplace(returnMatrix); } returnMatrix.mmuli((double) (factorRow * factorCol)); return returnMatrix; }
SarUtils { public static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol) throws IllegalArgumentException { final int l = inputMatrix.rows; final int p = inputMatrix.columns; final int halfL = l / 2; final int halfP = p / 2; final int L2 = factorRow * l; final int P2 = factorCol * p; if (inputMatrix.isVector()) { logger.error("oversample: only 2d matrices."); throw new IllegalArgumentException("oversample: only 2d matrices"); } if (!MathUtils.isPower2(l) && factorRow != 1) { logger.error("oversample: numlines != 2^n"); throw new IllegalArgumentException("oversample: numlines != 2^n"); } if (!MathUtils.isPower2(p) && factorCol != 1) { logger.error("oversample: numcols != 2^n"); throw new IllegalArgumentException("oversample: numcols != 2^n"); } if (factorRow == 1 && factorCol == 1) { logger.info("oversample: both azimuth and range oversampling factors equal to 1!"); logger.info("oversample: returning inputMatrix!"); return inputMatrix; } final ComplexDouble half = new ComplexDouble(0.5); ComplexDoubleMatrix returnMatrix = new ComplexDoubleMatrix(L2, P2); final Window winA1; final Window winA2; final Window winR2; ComplexDoubleMatrix tempMatrix; if (factorRow == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 2); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); winA1 = new Window(0, l - 1, 0, halfP); winA2 = new Window(0, l - 1, halfP, p - 1); winR2 = new Window(0, l - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 2); } else if (factorCol == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 1); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmul(half)); winA1 = new Window(0, halfL, 0, p - 1); winR2 = new Window(L2 - halfL, L2 - 1, 0, p - 1); winA2 = new Window(halfL, l - 1, 0, p - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 1); } else { Window winA3; Window winA4; Window winR3; Window winR4; tempMatrix = SpectralUtils.fft2D(inputMatrix); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmuli(half)); winA1 = new Window(0, halfL, 0, halfP); winA2 = new Window(0, halfL, halfP, p - 1); winA3 = new Window(halfL, l - 1, 0, halfP); winA4 = new Window(halfL, l - 1, halfP, p - 1); winR2 = new Window(0, halfL, P2 - halfP, P2 - 1); winR3 = new Window(L2 - halfL, L2 - 1, 0, halfP); winR4 = new Window(L2 - halfL, L2 - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); LinearAlgebraUtils.setdata(returnMatrix, winR3, tempMatrix, winA3); LinearAlgebraUtils.setdata(returnMatrix, winR4, tempMatrix, winA4); SpectralUtils.invfft2D_inplace(returnMatrix); } returnMatrix.mmuli((double) (factorRow * factorCol)); return returnMatrix; } }
SarUtils { public static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol) throws IllegalArgumentException { final int l = inputMatrix.rows; final int p = inputMatrix.columns; final int halfL = l / 2; final int halfP = p / 2; final int L2 = factorRow * l; final int P2 = factorCol * p; if (inputMatrix.isVector()) { logger.error("oversample: only 2d matrices."); throw new IllegalArgumentException("oversample: only 2d matrices"); } if (!MathUtils.isPower2(l) && factorRow != 1) { logger.error("oversample: numlines != 2^n"); throw new IllegalArgumentException("oversample: numlines != 2^n"); } if (!MathUtils.isPower2(p) && factorCol != 1) { logger.error("oversample: numcols != 2^n"); throw new IllegalArgumentException("oversample: numcols != 2^n"); } if (factorRow == 1 && factorCol == 1) { logger.info("oversample: both azimuth and range oversampling factors equal to 1!"); logger.info("oversample: returning inputMatrix!"); return inputMatrix; } final ComplexDouble half = new ComplexDouble(0.5); ComplexDoubleMatrix returnMatrix = new ComplexDoubleMatrix(L2, P2); final Window winA1; final Window winA2; final Window winR2; ComplexDoubleMatrix tempMatrix; if (factorRow == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 2); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); winA1 = new Window(0, l - 1, 0, halfP); winA2 = new Window(0, l - 1, halfP, p - 1); winR2 = new Window(0, l - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 2); } else if (factorCol == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 1); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmul(half)); winA1 = new Window(0, halfL, 0, p - 1); winR2 = new Window(L2 - halfL, L2 - 1, 0, p - 1); winA2 = new Window(halfL, l - 1, 0, p - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 1); } else { Window winA3; Window winA4; Window winR3; Window winR4; tempMatrix = SpectralUtils.fft2D(inputMatrix); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmuli(half)); winA1 = new Window(0, halfL, 0, halfP); winA2 = new Window(0, halfL, halfP, p - 1); winA3 = new Window(halfL, l - 1, 0, halfP); winA4 = new Window(halfL, l - 1, halfP, p - 1); winR2 = new Window(0, halfL, P2 - halfP, P2 - 1); winR3 = new Window(L2 - halfL, L2 - 1, 0, halfP); winR4 = new Window(L2 - halfL, L2 - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); LinearAlgebraUtils.setdata(returnMatrix, winR3, tempMatrix, winA3); LinearAlgebraUtils.setdata(returnMatrix, winR4, tempMatrix, winA4); SpectralUtils.invfft2D_inplace(returnMatrix); } returnMatrix.mmuli((double) (factorRow * factorCol)); return returnMatrix; }  }
SarUtils { public static ComplexDoubleMatrix oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol) throws IllegalArgumentException { final int l = inputMatrix.rows; final int p = inputMatrix.columns; final int halfL = l / 2; final int halfP = p / 2; final int L2 = factorRow * l; final int P2 = factorCol * p; if (inputMatrix.isVector()) { logger.error("oversample: only 2d matrices."); throw new IllegalArgumentException("oversample: only 2d matrices"); } if (!MathUtils.isPower2(l) && factorRow != 1) { logger.error("oversample: numlines != 2^n"); throw new IllegalArgumentException("oversample: numlines != 2^n"); } if (!MathUtils.isPower2(p) && factorCol != 1) { logger.error("oversample: numcols != 2^n"); throw new IllegalArgumentException("oversample: numcols != 2^n"); } if (factorRow == 1 && factorCol == 1) { logger.info("oversample: both azimuth and range oversampling factors equal to 1!"); logger.info("oversample: returning inputMatrix!"); return inputMatrix; } final ComplexDouble half = new ComplexDouble(0.5); ComplexDoubleMatrix returnMatrix = new ComplexDoubleMatrix(L2, P2); final Window winA1; final Window winA2; final Window winR2; ComplexDoubleMatrix tempMatrix; if (factorRow == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 2); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); winA1 = new Window(0, l - 1, 0, halfP); winA2 = new Window(0, l - 1, halfP, p - 1); winR2 = new Window(0, l - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 2); } else if (factorCol == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 1); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmul(half)); winA1 = new Window(0, halfL, 0, p - 1); winR2 = new Window(L2 - halfL, L2 - 1, 0, p - 1); winA2 = new Window(halfL, l - 1, 0, p - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 1); } else { Window winA3; Window winA4; Window winR3; Window winR4; tempMatrix = SpectralUtils.fft2D(inputMatrix); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmuli(half)); winA1 = new Window(0, halfL, 0, halfP); winA2 = new Window(0, halfL, halfP, p - 1); winA3 = new Window(halfL, l - 1, 0, halfP); winA4 = new Window(halfL, l - 1, halfP, p - 1); winR2 = new Window(0, halfL, P2 - halfP, P2 - 1); winR3 = new Window(L2 - halfL, L2 - 1, 0, halfP); winR4 = new Window(L2 - halfL, L2 - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); LinearAlgebraUtils.setdata(returnMatrix, winR3, tempMatrix, winA3); LinearAlgebraUtils.setdata(returnMatrix, winR4, tempMatrix, winA4); SpectralUtils.invfft2D_inplace(returnMatrix); } returnMatrix.mmuli((double) (factorRow * factorCol)); return returnMatrix; }  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 oversample(ComplexDoubleMatrix inputMatrix, final int factorRow, final int factorCol) throws IllegalArgumentException { final int l = inputMatrix.rows; final int p = inputMatrix.columns; final int halfL = l / 2; final int halfP = p / 2; final int L2 = factorRow * l; final int P2 = factorCol * p; if (inputMatrix.isVector()) { logger.error("oversample: only 2d matrices."); throw new IllegalArgumentException("oversample: only 2d matrices"); } if (!MathUtils.isPower2(l) && factorRow != 1) { logger.error("oversample: numlines != 2^n"); throw new IllegalArgumentException("oversample: numlines != 2^n"); } if (!MathUtils.isPower2(p) && factorCol != 1) { logger.error("oversample: numcols != 2^n"); throw new IllegalArgumentException("oversample: numcols != 2^n"); } if (factorRow == 1 && factorCol == 1) { logger.info("oversample: both azimuth and range oversampling factors equal to 1!"); logger.info("oversample: returning inputMatrix!"); return inputMatrix; } final ComplexDouble half = new ComplexDouble(0.5); ComplexDoubleMatrix returnMatrix = new ComplexDoubleMatrix(L2, P2); final Window winA1; final Window winA2; final Window winR2; ComplexDoubleMatrix tempMatrix; if (factorRow == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 2); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); winA1 = new Window(0, l - 1, 0, halfP); winA2 = new Window(0, l - 1, halfP, p - 1); winR2 = new Window(0, l - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 2); } else if (factorCol == 1) { tempMatrix = SpectralUtils.fft(inputMatrix, 1); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmul(half)); winA1 = new Window(0, halfL, 0, p - 1); winR2 = new Window(L2 - halfL, L2 - 1, 0, p - 1); winA2 = new Window(halfL, l - 1, 0, p - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); SpectralUtils.invfft_inplace(returnMatrix, 1); } else { Window winA3; Window winA4; Window winR3; Window winR4; tempMatrix = SpectralUtils.fft2D(inputMatrix); tempMatrix.putColumn(halfP, tempMatrix.getColumn(halfP).mmuli(half)); tempMatrix.putRow(halfL, tempMatrix.getRow(halfL).mmuli(half)); winA1 = new Window(0, halfL, 0, halfP); winA2 = new Window(0, halfL, halfP, p - 1); winA3 = new Window(halfL, l - 1, 0, halfP); winA4 = new Window(halfL, l - 1, halfP, p - 1); winR2 = new Window(0, halfL, P2 - halfP, P2 - 1); winR3 = new Window(L2 - halfL, L2 - 1, 0, halfP); winR4 = new Window(L2 - halfL, L2 - 1, P2 - halfP, P2 - 1); LinearAlgebraUtils.setdata(returnMatrix, winA1, tempMatrix, winA1); LinearAlgebraUtils.setdata(returnMatrix, winR2, tempMatrix, winA2); LinearAlgebraUtils.setdata(returnMatrix, winR3, tempMatrix, winA3); LinearAlgebraUtils.setdata(returnMatrix, winR4, tempMatrix, winA4); SpectralUtils.invfft2D_inplace(returnMatrix); } returnMatrix.mmuli((double) (factorRow * factorCol)); return returnMatrix; }  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);  }