public final class SRG3D extends DefaultProgressReporter
Seeded region growing algorithm based on article by Rolf Adams and Leanne Bischof, "Seeded Region Growing", IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 16, no. 6, June 1994.
The algorithm assumes that seeds for objects and the background be provided. Seeds are used to compute initial mean gray level for each region. The condition of growth is difference of a gray level of a candidate pixel and mean grey level intensity of a neighboring region. At each step of the algorithm a candidate with a smallest difference to some neighboring region is added to that region and all neighboring points of that that are not yet assigned to any region are added to candidate list.
Part of the image that will be segmented can be restricted by setting a mask.
Progress of segmentation can be recorded on a animation stack.
To enable recording set numberOfAnimationFrames
to a value larger than 0.
An example of segmenting an image is below. Seeds are set for three regions: background, blob 1, and blob 2.
// Setup growing final ImageStack image = ...; final Point3DInt[][] seeds = { {new Point3DInt(107, 144, 1)}, // Background {new Point3DInt(91, 159, 100)}, // Blob 1 {new Point3DInt(119, 143, 51)}, // Blob 2 }; final SRG3D srg = new SRG3D(); srg.setImage(image); srg.setSeeds(seeds); // Run growing srg.run(); // Extract results final ImageStack regionMask = srg.getRegionMarkers();
If ImageJ is set to debug mode (IJ.debugMode
property is true
) additional information will be printed to
output window (using IJ.log()
).
History of growing can be saved using setGrowHistoryEnabled(boolean)
and
setGrowHistoryDirectory(java.io.File)
.
Saved images represent internal representation of growing regions including 0xff
marking of candidate voxels
(that were not yet assigned to a region).
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GROW_HISTORY_FILE_FORMAT |
Constructor and Description |
---|
SRG3D() |
Modifier and Type | Method and Description |
---|---|
java.io.File |
getGrowHistoryDirectory() |
ij.ImageStack |
getRegionMarkers() |
boolean |
isGrowHistoryEnabled() |
void |
run()
Perform region growing.
|
void |
setGrowHistoryDirectory(java.io.File growHistoryDirectory)
Directory where to save marker history growth.
|
void |
setGrowHistoryEnabled(boolean growHistoryEnabled)
Enable saving of images containing grow markers.
|
void |
setImage(ij.ImageStack image)
Set image to be segmented.
|
void |
setMask(ij.ImageStack mask)
Set ROI mask, if not set full image is processed.
|
void |
setSeeds(ij.ImageStack seeds) |
static ij.ImageStack |
toSeedImage(Point3DInt[][] seeds,
int xSize,
int ySize,
int zSize)
Convert array of point seeds to a seed image.
|
addProgressListener, currentProgress, notifyProgressListeners, notifyProgressListeners, notifyProgressListeners, removeAllProgressListener, removeProgressListener, setCurrentProgress
public static final java.lang.String GROW_HISTORY_FILE_FORMAT
public void setImage(ij.ImageStack image)
image
- image.public void setSeeds(ij.ImageStack seeds)
public void setMask(ij.ImageStack mask)
mask
- Mask of the region of interest used for processing.public ij.ImageStack getRegionMarkers()
public boolean isGrowHistoryEnabled()
public void setGrowHistoryEnabled(boolean growHistoryEnabled)
setGrowHistoryDirectory(java.io.File)
.growHistoryEnabled
- if true
saving is enabled.public java.io.File getGrowHistoryDirectory()
public void setGrowHistoryDirectory(java.io.File growHistoryDirectory)
growHistoryDirectory
- grow history directory.setGrowHistoryEnabled(boolean)
public void run()
public static ij.ImageStack toSeedImage(Point3DInt[][] seeds, int xSize, int ySize, int zSize)
Convert array of point seeds to a seed image.
The first index in the seeds
array refers to the region.
Region number if the first index + 1.
Second index is a seeds with a region.
seeds
cannot be link
null.seeds
- region seeds.xSize
- width of the seed imageySize
- height of the seed imagezSize
- number of slices