Search in sources :

Example 1 with PhaseFilter

use of org.jlinda.core.filtering.PhaseFilter in project s1tbx by senbox-org.

the class PhaseFilterOp method computeTileStack.

@Override
public void computeTileStack(Map<Band, Tile> targetTileMap, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException {
    try {
        // String filterType = "goldstein";
        // final float alpha = (float) 0.75;
        // final int overlap = 8;
        // final double[] kernel = new double[]{1. / 5, 1. / 5, 1. / 5, 1. / 5, 1. / 5};
        // final int blockSize = 64;
        Band targetBand_I;
        Band targetBand_Q;
        final Rectangle rectIn = new Rectangle(targetRectangle);
        final Rectangle rectOut = new Rectangle(targetRectangle);
        rectIn.y -= (overlap);
        rectIn.height += (2 * overlap);
        rectIn.x -= (overlap);
        rectIn.width += (2 * overlap);
        for (String ifgKey : targetMap.keySet()) {
            ProductContainer product = targetMap.get(ifgKey);
            Tile tileReal = getSourceTile(product.sourceMaster.realBand, rectIn);
            Tile tileImag = getSourceTile(product.sourceMaster.imagBand, rectIn);
            // put interferogram together
            ComplexDoubleMatrix complexIfg = TileUtilsDoris.pullComplexDoubleMatrix(tileReal, tileImag);
            PhaseFilter phaseFilter = new PhaseFilter(method, complexIfg, blockSize, overlap, kernelArray, alpha);
            phaseFilter.filter();
            complexIfg = phaseFilter.getData();
            // commit to target [note the tile overlap and boundary because of filter]
            // output [x0,y0] is shifted because of the tile overlap
            targetBand_I = targetProduct.getBand(product.targetBandName_I);
            Tile tileOutReal = targetTileMap.get(targetBand_I);
            TileUtilsDoris.pushDoubleMatrix(complexIfg.real(), tileOutReal, rectOut, overlap, overlap);
            targetBand_Q = targetProduct.getBand(product.targetBandName_Q);
            Tile tileOutImag = targetTileMap.get(targetBand_Q);
            TileUtilsDoris.pushDoubleMatrix(complexIfg.imag(), tileOutImag, rectOut, overlap, overlap);
        }
    } catch (Exception e) {
        throw new OperatorException(e);
    }
}
Also used : ProductContainer(org.jlinda.core.utils.ProductContainer) PhaseFilter(org.jlinda.core.filtering.PhaseFilter) Tile(org.esa.snap.core.gpf.Tile) Band(org.esa.snap.core.datamodel.Band) OperatorException(org.esa.snap.core.gpf.OperatorException) OperatorException(org.esa.snap.core.gpf.OperatorException) ComplexDoubleMatrix(org.jblas.ComplexDoubleMatrix)

Aggregations

Band (org.esa.snap.core.datamodel.Band)1 OperatorException (org.esa.snap.core.gpf.OperatorException)1 Tile (org.esa.snap.core.gpf.Tile)1 ComplexDoubleMatrix (org.jblas.ComplexDoubleMatrix)1 PhaseFilter (org.jlinda.core.filtering.PhaseFilter)1 ProductContainer (org.jlinda.core.utils.ProductContainer)1