/** * Fills the region connected to the specified start pixel. * A pixel belongs to this region if there is a path between it and the starting * pixel which passes only through pixels of value {@code v} within the range * {@code start_pixel_value - tolerance <= v <= start_pixel_value + tolerance}. * * @param x start pixel x coordinate * * @param y start pixel y coordinate * * @param fillValue the value to write to the destination image for this region * * @return a new {@linkplain FillResult} */ public FillResult fill(int x, int y, int fillValue) { return fill(x, y, fillValue, srcIter.getSampleDouble(x, y, srcBand)); }
/** * Fills the region connected to the specified start pixel. * A pixel belongs to this region if there is a path between it and the starting * pixel which passes only through pixels of value {@code v} within the range * {@code refValue - tolerance <= v <= refValue + tolerance}. * * @param x start pixel x coordinate * * @param y start pixel y coordinate * * @param fillValue the value to write to the destination image for this region * * @param refValue the source image reference value for the region * * @return a new {@linkplain FillResult} */ public FillResult fill(int x, int y, int fillValue, double refValue) { return fillRadius(x, y, fillValue, refValue, Double.NaN); }
setTileCache( regionImage.getTileCache() ); filler = new FloodFiller(source, band, regionImage, 0, tolerance, diagonal); regions = CollectionFactory.sortedMap();
segmentsFilled = new ArrayList<ScanSegment>(); fillSegment(x, y, destIter); int xi = startX; while (xi <= endX) { newSegment = fillSegment(xi, segment.y - 1, destIter); xi = newSegment != null ? newSegment.endX+1 : xi+1; int xi = startX; while (xi <= endX) { newSegment = fillSegment(xi, segment.y + 1, destIter); xi = newSegment != null ? newSegment.endX+1 : xi+1;
if (checkPixel(xi, y)) { destIter.setSample(xi, y, destBand, fillValue); fill = true; if (checkPixel(xi, y)) { destIter.setSample(xi, y, destBand, fillValue); right = xi;
setTileCache( regionImage.getTileCache() ); filler = new FloodFiller(source, band, regionImage, 0, tolerance, diagonal); regions = CollectionFactory.sortedMap();
@Override public Raster computeTile(int tileX, int tileY) { Rectangle destRect = getTileRect(tileX, tileY); synchronized (computeTileLock) { for (int destY = destRect.y, row = 0; row < destRect.height; destY++, row++) { for (int destX = destRect.x, col = 0; col < destRect.width; destX++, col++) { if (getRegionForPixel(destX, destY) == NO_REGION) { FillResult fill = filler.fill(destX, destY, currentID); regions.put(currentID, new Region(fill)); currentID++; } } } tileComputed[getTileIndex(tileX, tileY)] = true; } return regionImage.getTile(tileX, tileY); }
/** * Fills the region connected to the specified start pixel and lying within * {@code radius} pixels of the start pixel. * <p> * A pixel belongs to this region if there is a path between it and the starting * pixel which passes only through pixels of value {@code v} within the range * {@code start_pixel_value - tolerance <= v <= start_pixel_value + tolerance}. * * @param x start pixel x coordinate * * @param y start pixel y coordinate * * @param fillValue the value to write to the destination image for this region * * @param radius maximum distance (pixels) that a candidate pixel can be from * the start pixel * * @return a new {@linkplain FillResult} */ public FillResult fillRadius(int x, int y, int fillValue, double radius) { return fillRadius(x, y, fillValue, srcIter.getSampleDouble(x, y, srcBand), radius); }
@Override public Raster computeTile(int tileX, int tileY) { Rectangle destRect = getTileRect(tileX, tileY); synchronized (computeTileLock) { for (int destY = destRect.y, row = 0; row < destRect.height; destY++, row++) { for (int destX = destRect.x, col = 0; col < destRect.width; destX++, col++) { if (getRegionForPixel(destX, destY) == NO_REGION) { FillResult fill = filler.fill(destX, destY, currentID); regions.put(currentID, new Region(fill)); currentID++; } } } tileComputed[getTileIndex(tileX, tileY)] = true; } return regionImage.getTile(tileX, tileY); }