public class FloodFiller extends Object
The code is adapted from an algorithm published in C# by J. Dunlap at:
http://www.codeproject.com/KB/GDI-plus/queuelinearfloodfill.aspxwhich was subsequently ported to Java by Owen Kaluza. The JAITools implementation is substantially different and any bugs should not be blamed on the above authors.
This version works with a source RenderedImage and a destination
WritableRenderedImage, both of which are accessed using JAI iterators.
| Modifier and Type | Class and Description |
|---|---|
static class |
FloodFiller.ScanSegment
Records a segment of contiguous pixels in a single row that will
become part of a filled region.
|
| Constructor and Description |
|---|
FloodFiller(RenderedImage sourceImage,
int sourceBand,
WritableRenderedImage destImage,
int destBand,
double tolerance,
boolean diagonal)
Create a FloodFiller to work with the given source image
|
| Modifier and Type | Method and Description |
|---|---|
FillResult |
fill(int x,
int y,
int fillValue)
Fills the region connected to the specified start pixel.
|
FillResult |
fill(int x,
int y,
int fillValue,
double refValue)
Fills the region connected to the specified start pixel.
|
FillResult |
fillRadius(int x,
int y,
int fillValue,
double radius)
Fills the region connected to the specified start pixel and lying within
radius pixels of the start pixel. |
FillResult |
fillRadius(int x,
int y,
int fillValue,
double refValue,
double radius)
Fills the region connected to the specified start pixel and lying within
radius pixels of the start pixel. |
public FloodFiller(RenderedImage sourceImage, int sourceBand, WritableRenderedImage destImage, int destBand, double tolerance, boolean diagonal)
sourceImage - the source imagedestImage - the destination imagesourceBand - the source image band to be processeddestBand - the destination image band to write totolerance - the maximum absolute difference in value for a pixel to be
included in the regiondiagonal - set to true to include sub-regions that are only connected
diagonally; set to false to require orthogonal connectionspublic FillResult fill(int x, int y, int fillValue)
v within the range
start_pixel_value - tolerance <= v <= start_pixel_value + tolerance.x - start pixel x coordinatey - start pixel y coordinatefillValue - the value to write to the destination image for this regionpublic FillResult fillRadius(int x, int y, int fillValue, double radius)
radius pixels of the 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 v within the range
start_pixel_value - tolerance <= v <= start_pixel_value + tolerance.
x - start pixel x coordinatey - start pixel y coordinatefillValue - the value to write to the destination image for this regionradius - maximum distance (pixels) that a candidate pixel can be from
the start pixelpublic FillResult fill(int x, int y, int fillValue, double refValue)
v within the range
refValue - tolerance <= v <= refValue + tolerance.x - start pixel x coordinatey - start pixel y coordinatefillValue - the value to write to the destination image for this regionrefValue - the source image reference value for the regionpublic FillResult fillRadius(int x, int y, int fillValue, double refValue, double radius)
radius pixels of the 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 v within the range
refValue - tolerance <= v <= refValue + tolerance.
x - start pixel x coordinatey - start pixel y coordinatefillValue - the value to write to the destination image for this regionrefValue - the source image reference value for the regionradius - maximum distance (pixels) that a candidate pixel can be from
the start pixelCopyright © 2009–2018. All rights reserved.