private static void searchNeighbourhood(final PixelPos pixel, final int x0, final int y0, final int w, final int h, final ProductData bitMaskData, final Tile bitMaskTile, final int[][] pixelsScaned, final List<PixelPos> clusterPixels, final List<PixelPos> newSeeds) { final int xc = (int) pixel.x; final int yc = (int) pixel.y; final int[] x = {xc - 1, xc, xc + 1, xc - 1, xc + 1, xc - 1, xc, xc + 1}; final int[] y = {yc - 1, yc - 1, yc - 1, yc, yc, yc + 1, yc + 1, yc + 1}; for (int i = 0; i < 8; i++) { if (x[i] >= x0 && x[i] < x0 + w && y[i] >= y0 && y[i] < y0 + h && pixelsScaned[y[i] - y0][x[i] - x0] == 0 && bitMaskData.getElemIntAt(bitMaskTile.getDataBufferIndex(x[i], y[i])) == 1) { pixelsScaned[y[i] - y0][x[i] - x0] = 1; clusterPixels.add(new PixelPos(x[i], y[i])); newSeeds.add(new PixelPos(x[i], y[i])); } } }
private static Object getDataElemArray(ProductData data, int index) { switch (data.getType()) { case TYPE_INT8: return new byte[]{(byte)data.getElemIntAt(index)}; case TYPE_INT16: return new short[]{(short)data.getElemIntAt(index)}; case TYPE_INT32: return new int[]{data.getElemIntAt(index)}; case TYPE_UINT8: return new byte[]{(byte)data.getElemUIntAt(index)}; case TYPE_UINT16: return new short[]{(short)data.getElemUIntAt(index)}; case TYPE_UINT32: return new int[]{(int)data.getElemUIntAt(index)}; case TYPE_INT64: return new long[]{data.getElemLongAt(index)}; case TYPE_FLOAT32: return new float[]{data.getElemFloatAt(index)}; case TYPE_FLOAT64: return new double[]{data.getElemDoubleAt(index)}; default: return null; } } }
/** * Find pixels detected as target in a 3x3 window centered at a given point. * * @param xc The x coordinate of the given point. * @param yc The y coordinate of the given point. * @param x0 The x coordinate for the upper left corner point of the source rectangle. * @param y0 The y coordinate for the upper left corner point of the source rectangle. * @param w The width of the source rectangle. * @param h The height of the source rectangle. * @param bitMaskData The bit maks band data. * @param bitMaskTile The bit mask band tile. * @param pixelsScanned The binary array indicating which pixel in the tile has been scaned. * @param clusterPixels The list of pixels in the cluster. */ private static void clustering(final int xc, final int yc, final int x0, final int y0, final int w, final int h, final ProductData bitMaskData, final Tile bitMaskTile, final int[][] pixelsScanned, List<PixelPos> clusterPixels) { pixelsScanned[yc - y0][xc - x0] = 1; clusterPixels.add(new PixelPos(xc, yc)); final int[] x = {xc - 1, xc, xc + 1, xc - 1, xc + 1, xc - 1, xc, xc + 1}; final int[] y = {yc - 1, yc - 1, yc - 1, yc, yc, yc + 1, yc + 1, yc + 1}; for (int i = 0; i < 8; i++) { if (x[i] >= x0 && x[i] < x0 + w && y[i] >= y0 && y[i] < y0 + h && pixelsScanned[y[i] - y0][x[i] - x0] == 0 && bitMaskData.getElemIntAt(bitMaskTile.getDataBufferIndex(x[i], y[i])) == 1) { clustering(x[i], y[i], x0, y0, w, h, bitMaskData, bitMaskTile, pixelsScanned, clusterPixels); } } }
if (bitMaskData.getElemIntAt(srcIndex.getIndex(tx)) == 1) {
for (int tx = tx0; tx < maxx; tx++) { if (pixelsScaned[ty - y0][tx - x0] == 0 && srcData.getElemIntAt(srcIndex.getIndex(tx)) == 1) {
} else { if (isInt) trgData.setElemIntAt(tx - trgOffset, srcData.getElemIntAt(sx - srcOffset)); else trgData.setElemDoubleAt(tx - trgOffset, srcData.getElemDoubleAt(sx - srcOffset));
final int gim = srcGIMData.getElemIntAt(srcIdx); inciAng = (gim - (gim % 10)) / 100.0 * Constants.DTOR; } else {
if (noDataValue.equals(v) || (maskBand != null && maskData.getElemIntAt(idx) == 1)) { trgData.setElemFloatAt(idx, noDataValue.floatValue()); continue;