private static void saveT3(final double[][] Tr, final double[][] Ti, final int idx, final ProductData[] targetDataBuffers) { targetDataBuffers[0].setElemFloatAt(idx, (float) Tr[0][0]); // T11 targetDataBuffers[1].setElemFloatAt(idx, (float) Tr[0][1]); // T12_real targetDataBuffers[2].setElemFloatAt(idx, (float) Ti[0][1]); // T12_imag targetDataBuffers[3].setElemFloatAt(idx, (float) Tr[0][2]); // T13_real targetDataBuffers[4].setElemFloatAt(idx, (float) Ti[0][2]); // T13_imag targetDataBuffers[5].setElemFloatAt(idx, (float) Tr[1][1]); // T22 targetDataBuffers[6].setElemFloatAt(idx, (float) Tr[1][2]); // T23_real targetDataBuffers[7].setElemFloatAt(idx, (float) Ti[1][2]); // T23_imag targetDataBuffers[8].setElemFloatAt(idx, (float) Tr[2][2]); // T33 }
private static void saveC2(final double[][] Cr, final double[][] Ci, final int idx, final ProductData[] targetDataBuffers) { targetDataBuffers[0].setElemFloatAt(idx, (float) Cr[0][0]); // C11 targetDataBuffers[1].setElemFloatAt(idx, (float) Cr[0][1]); // C12_real targetDataBuffers[2].setElemFloatAt(idx, (float) Ci[0][1]); // C12_imag targetDataBuffers[3].setElemFloatAt(idx, (float) Cr[1][1]); // C22 }
private static void saveC2(final CovarianceMatrix sigmaNLRB, final int idx, final ProductData[] targetDataBuffers) { final double[][] Cr = sigmaNLRB.getRealCovarianceMatrix(); final double[][] Ci = sigmaNLRB.getImagCovarianceMatrix(); targetDataBuffers[0].setElemFloatAt(idx, (float) Cr[0][0]); // C11 targetDataBuffers[1].setElemFloatAt(idx, (float) Cr[0][1]); // C12_real targetDataBuffers[2].setElemFloatAt(idx, (float) Ci[0][1]); // C12_imag targetDataBuffers[3].setElemFloatAt(idx, (float) Cr[1][1]); // C22 }
private static void saveC3(final CovarianceMatrix sigmaNLRB, final int idx, final ProductData[] targetDataBuffers) { final double[][] Cr = sigmaNLRB.getRealCovarianceMatrix(); final double[][] Ci = sigmaNLRB.getImagCovarianceMatrix(); targetDataBuffers[0].setElemFloatAt(idx, (float) Cr[0][0]); // C11 targetDataBuffers[1].setElemFloatAt(idx, (float) Cr[0][1]); // C12_real targetDataBuffers[2].setElemFloatAt(idx, (float) Ci[0][1]); // C12_imag targetDataBuffers[3].setElemFloatAt(idx, (float) Cr[0][2]); // C13_real targetDataBuffers[4].setElemFloatAt(idx, (float) Ci[0][2]); // C13_imag targetDataBuffers[5].setElemFloatAt(idx, (float) Cr[1][1]); // C22 targetDataBuffers[6].setElemFloatAt(idx, (float) Cr[1][2]); // C23_real targetDataBuffers[7].setElemFloatAt(idx, (float) Ci[1][2]); // C23_imag targetDataBuffers[8].setElemFloatAt(idx, (float) Cr[2][2]); // C33 }
private void saveT3(final double[][] Tr, final double[][] Ti, final int idx, final double theta, final ProductData[] targetDataBuffers) { targetDataBuffers[0].setElemFloatAt(idx, (float) Tr[0][0]); // T11 targetDataBuffers[1].setElemFloatAt(idx, (float) Tr[0][1]); // T12_real targetDataBuffers[2].setElemFloatAt(idx, (float) Ti[0][1]); // T12_imag targetDataBuffers[3].setElemFloatAt(idx, (float) Tr[0][2]); // T13_real targetDataBuffers[4].setElemFloatAt(idx, (float) Ti[0][2]); // T13_imag targetDataBuffers[5].setElemFloatAt(idx, (float) Tr[1][1]); // T22 targetDataBuffers[6].setElemFloatAt(idx, (float) Tr[1][2]); // T23_real targetDataBuffers[7].setElemFloatAt(idx, (float) Ti[1][2]); // T23_imag targetDataBuffers[8].setElemFloatAt(idx, (float) Tr[2][2]); // T33 if (outputOrientationAngle) { targetDataBuffers[9].setElemFloatAt(idx, (float) theta); // Ori_Ang } }
private static void copyOneOfTwo(final ProductData tmpBuffer, final ProductData destBuffer) { final int numElems = destBuffer.getNumElems(); for (int x = 0, i = 0; x < numElems; ++x, i += 2) { destBuffer.setElemFloatAt(x, tmpBuffer.getElemFloatAt(i)); } }
private static void copyTwoOfTwo(final ProductData tmpBuffer, final ProductData destBuffer) { final int numElems = destBuffer.getNumElems(); for (int x = 0, i = 1; x < numElems; ++x, i += 2) { destBuffer.setElemFloatAt(x, tmpBuffer.getElemFloatAt(i)); } } }
public static void pushFloatMatrix(DoubleMatrix data, Tile tile, Rectangle rect) { final ProductData samples = tile.getRawSamples(); // checkout final int width = (int) rect.getWidth(); for (int y = 0, rowIdx = 0; y < rect.getHeight(); y++, rowIdx++) { final int stride = y * width; for (int x = 0, columnIdx = 0; x < rect.getWidth(); x++, columnIdx++) { samples.setElemFloatAt(stride + x, (float) data.get(rowIdx, columnIdx)); } } tile.setRawSamples(samples); // commit samples.dispose(); }
public static void pushFloatMatrix(FloatMatrix data, Tile tile, Rectangle rect) { ProductData samples = tile.getRawSamples(); // checkout final int width = tile.getWidth(); for (int y = 0, rowIdx = 0; y < rect.getHeight(); y++, rowIdx++) { final int stride = y * width; for (int x = 0, columnIdx = 0; x < rect.getWidth(); x++, columnIdx++) { samples.setElemFloatAt(stride + x, data.get(rowIdx, columnIdx)); } } tile.setRawSamples(samples); // commit samples.dispose(); }
public static void pushDoubleMatrix(final DoubleMatrix data, final Tile tile, final Rectangle rect) { final int maxX = rect.x + rect.width; final int maxY = rect.y + rect.height; final ProductData samples = tile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(tile); for (int y = rect.y; y < maxY; y++) { tgtIndex.calculateStride(y); final int yy = y - rect.y; for (int x = rect.x; x < maxX; x++) { samples.setElemFloatAt(tgtIndex.getIndex(x), (float)data.get(yy, x - rect.x)); } } }
private void saveTopoPhase(final int x0, final int xN, final int y0, final int yN, final double[][] topoPhase, final ProductContainer product, final Map<Band, Tile> targetTileMap) { final Band topoPhaseBand = targetProduct.getBand(product.getBandName(TOPO_PHASE)); final Tile topoPhaseTile = targetTileMap.get(topoPhaseBand); final ProductData topoPhaseData = topoPhaseTile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(topoPhaseTile); for (int y = y0; y <= yN; y++) { tgtIndex.calculateStride(y); final int yy = y - y0 + (cohWinAz - 1) / 2; for (int x = x0; x <= xN; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0 + (cohWinRg - 1) / 2; topoPhaseData.setElemFloatAt(tgtIdx, (float)topoPhase[yy][xx]); } } }
private void saveTopoPhase(final int x0, final int xN, final int y0, final int yN, final double[][] topoPhase, final ProductContainer product, final Map<Band, Tile> targetTileMap) { final Band topoPhaseBand = targetProduct.getBand(product.getBandName(TOPO_PHASE)); final Tile topoPhaseTile = targetTileMap.get(topoPhaseBand); final ProductData topoPhaseData = topoPhaseTile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(topoPhaseTile); for (int y = y0; y <= yN; y++) { tgtIndex.calculateStride(y); final int yy = y - y0; for (int x = x0; x <= xN; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0; topoPhaseData.setElemFloatAt(tgtIdx, (float)topoPhase[yy][xx]); } } }
public static void pushComplexFloatMatrix(ComplexDoubleMatrix cplxData, Tile tileReal, Tile tileImag, Rectangle rect) { // TOO SLOW? final int width = (int) rect.getWidth(); final int height = (int) rect.getHeight(); final ProductData samplesReal = tileReal.getRawSamples(); // checkout final ProductData samplesImag = tileImag.getRawSamples(); // checkout int arrayIdx; int row = 0; int column; for (int y = 0; y < height; y++) { column = 0; for (int x = 0; x < width; x++) { arrayIdx = y * width + x; samplesReal.setElemFloatAt(arrayIdx, (float) cplxData.real().get(row, column)); samplesImag.setElemFloatAt(arrayIdx, (float) cplxData.imag().get(row, column)); column++; } row++; } tileReal.setRawSamples(samplesReal); // commit tileImag.setRawSamples(samplesImag); // commit samplesImag.dispose(); samplesReal.dispose(); }
public static void pushDoubleArray2D(double[][] data, Tile tile, Rectangle rect) { /* final ProductData samples = tile.getRawSamples(); // checkout final int width = (int) rect.getWidth(); for (int y = 0, rowIdx = 0; y < rect.getHeight(); y++, rowIdx++) { final int stride = y * width; for (int x = 0, columnIdx = 0; x < rect.getWidth(); x++, columnIdx++) { samples.setElemDoubleAt(stride + x, data[rowIdx][columnIdx]); } } tile.setRawSamples(samples); // commit samples.dispose(); */ final int maxX = rect.x + rect.width; final int maxY = rect.y + rect.height; final ProductData samples = tile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(tile); for (int y = rect.y; y < maxY; y++) { tgtIndex.calculateStride(y); final int yy = y - rect.y; for (int x = rect.x; x < maxX; x++) { samples.setElemFloatAt(tgtIndex.getIndex(x), (float)data[yy][x - rect.x]); } } }
private void saveFlatEarthPhase(final int x0, final int xN, final int y0, final int yN, final DoubleMatrix refPhase, final ProductContainer product, final Map<Band, Tile> targetTileMap) { final Band flatEarthPhaseBand = targetProduct.getBand(product.getBandName(FLAT_EARTH_PHASE)); final Tile flatEarthPhaseTile = targetTileMap.get(flatEarthPhaseBand); final ProductData flatEarthPhaseData = flatEarthPhaseTile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(flatEarthPhaseTile); for (int y = y0; y <= yN; y++) { tgtIndex.calculateStride(y); final int yy = y - y0; for (int x = x0; x <= xN; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0; flatEarthPhaseData.setElemFloatAt(tgtIdx, (float)refPhase.get(yy, xx)); } } }
private void saveLatLon(final int x0, final int xN, final int y0, final int yN, final double[][] latitude, final double[][] longitude, final ProductContainer product, final Map<Band, Tile> targetTileMap) { if (product.getBandName(LATITUDE) == null || product.getBandName(LONGITUDE) == null) { return; } final Band latBand = targetProduct.getBand(product.getBandName(LATITUDE)); final Tile latTile = targetTileMap.get(latBand); final ProductData latData = latTile.getDataBuffer(); final Band lonBand = targetProduct.getBand(product.getBandName(LONGITUDE)); final Tile lonTile = targetTileMap.get(lonBand); final ProductData lonData = lonTile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(latTile); for (int y = y0; y <= yN; y++) { tgtIndex.calculateStride(y); final int yy = y - y0; for (int x = x0; x <= xN; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0; latData.setElemFloatAt(tgtIdx, (float) (latitude[yy][xx] * 180.0/Math.PI)); lonData.setElemFloatAt(tgtIdx, (float) (longitude[yy][xx] * 180.0/Math.PI)); } } }
private void saveFlatEarthPhase(final int x0, final int xN, final int y0, final int yN, final DoubleMatrix refPhase, final ProductContainer product, final Map<Band, Tile> targetTileMap) { final Band flatEarthPhaseBand = targetProduct.getBand(product.getBandName(FLAT_EARTH_PHASE)); final Tile flatEarthPhaseTile = targetTileMap.get(flatEarthPhaseBand); final ProductData flatEarthPhaseData = flatEarthPhaseTile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(flatEarthPhaseTile); for (int y = y0; y <= yN; y++) { tgtIndex.calculateStride(y); final int yy = y - y0 + (cohWinAz - 1) / 2; for (int x = x0; x <= xN; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0 + (cohWinRg - 1) / 2; flatEarthPhaseData.setElemFloatAt(tgtIdx, (float)refPhase.get(yy, xx)); } } }
public static void pushComplexDoubleMatrix( final ComplexDoubleMatrix data, final Tile tileI, final Tile tileQ, final Rectangle rect) { final int maxX = rect.x + rect.width; final int maxY = rect.y + rect.height; final ProductData samplesReal = tileI.getDataBuffer(); final ProductData samplesImag = tileQ.getDataBuffer(); final DoubleMatrix dataReal = data.real(); final DoubleMatrix dataImag = data.imag(); final TileIndex tgtIndex = new TileIndex(tileI); for (int y = rect.y; y < maxY; y++) { tgtIndex.calculateStride(y); final int yy = y - rect.y; for (int x = rect.x; x < maxX; x++) { final int xx = x - rect.x; samplesReal.setElemFloatAt(tgtIndex.getIndex(x), (float)dataReal.get(yy, xx)); samplesImag.setElemFloatAt(tgtIndex.getIndex(x), (float)dataImag.get(yy, xx)); } } }
private void saveElevation(final int x0, final int xN, final int y0, final int yN, final double[][] elevation, final ProductContainer product, final Map<Band, Tile> targetTileMap) { if (product.getBandName(ELEVATION) == null) { return; } final Band elevationBand = targetProduct.getBand(product.getBandName(ELEVATION)); final Tile elevationTile = targetTileMap.get(elevationBand); final ProductData elevationData = elevationTile.getDataBuffer(); final TileIndex tgtIndex = new TileIndex(elevationTile); for (int y = y0; y <= yN; y++) { tgtIndex.calculateStride(y); final int yy = y - y0; for (int x = x0; x <= xN; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0; elevationData.setElemFloatAt(tgtIdx, (float)elevation[yy][xx]); } } }
private void computeFilteredTile(final int x0, final int y0, final int maxX, final int maxY, final Rectangle sourceRectangle, final double[][] data, final double[][] span, final TileIndex trgIndex, final ProductData dataBuffer) { final int filterSize2 = filterSize * filterSize; final double[][] neighborSpanValues = new double[filterSize][filterSize]; final double[][] neighborPixelValues = new double[filterSize][filterSize]; for (int y = y0; y < maxY; ++y) { trgIndex.calculateStride(y); for (int x = x0; x < maxX; ++x) { final int n = getLocalData(x, y, sourceRectangle, data, span, neighborPixelValues, neighborSpanValues); double v; if (n < filterSize2) { v = computePixelValueUsingLocalStatistics(neighborPixelValues); } else { v = computePixelValueUsingEdgeDetection(neighborPixelValues, neighborSpanValues); } dataBuffer.setElemFloatAt(trgIndex.getIndex(x), (float) v); } } }