public final class SRG 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 ByteProcessor image = ...; final Point[][] seeds = { {new Point(107, 144)}, // Background {new Point(91, 159)}, // Blob 1 {new Point(119, 143)}, // Blob 2 }; final SRG srg = new SRG(); srg.setImage(image); srg.setSeeds(seeds); srg.setNumberOfAnimationFrames(50); // Run growing srg.run(); // Extract results final ByteProcessor regionMask = srg.getRegionMarkers(); final ImageStack animationStack = srg.getAnimationStack();
Modifier and Type | Class and Description |
---|---|
protected static class |
net.sf.ij_plugins.im3d.grow.SRG2DBase.RegionInfo |
Modifier and Type | Field and Description |
---|---|
protected int |
xSize |
protected int |
ySize |
Constructor and Description |
---|
SRG() |
Modifier and Type | Method and Description |
---|---|
protected double |
distanceFromMean(int offset,
net.sf.ij_plugins.im3d.grow.SRG2DBase.RegionInfo regionInfo) |
ij.ImageStack |
getAnimationStack()
Return progress of growing.
|
ij.process.ByteProcessor |
getRegionMarkers() |
protected void |
initializeImageStructures() |
protected void |
initializeStructures() |
protected net.sf.ij_plugins.im3d.grow.SRG2DBase.RegionInfo |
newRegionInfo(int originalSeedID) |
void |
run()
Perform region growing.
|
void |
setImage(ij.process.ByteProcessor image)
Set image to be segmented.
|
void |
setImage(ij.process.FloatProcessor image)
Set image to be segmented.
|
void |
setImage(ij.process.ImageProcessor image)
Set image to be segmented.
|
void |
setImage(ij.process.ShortProcessor image)
Set image to be segmented.
|
void |
setMask(ij.process.ByteProcessor mask)
Set ROI mask, if not set full image is processed.
|
void |
setNumberOfAnimationFrames(int numberOfAnimationFrames)
Sets how many animation frames should be recorded.
|
void |
setSeeds(ij.process.ByteProcessor seeds)
Set region seeds.
|
static ij.process.ByteProcessor |
toSeedImage(java.awt.Point[][] seeds,
int width,
int height)
Convert array of point seeds to a seed image.
|
addProgressListener, currentProgress, notifyProgressListeners, notifyProgressListeners, notifyProgressListeners, removeAllProgressListener, removeProgressListener, setCurrentProgress
public void setImage(ij.process.ImageProcessor image)
ByteProcessor
, ShortProcessor
, and FloatProcessor
.image
- image.public void setImage(ij.process.ByteProcessor image)
image
- image.public void setImage(ij.process.ShortProcessor image)
image
- image.public void setImage(ij.process.FloatProcessor image)
image
- image.protected double distanceFromMean(int offset, net.sf.ij_plugins.im3d.grow.SRG2DBase.RegionInfo regionInfo)
protected void initializeImageStructures()
protected net.sf.ij_plugins.im3d.grow.SRG2DBase.RegionInfo newRegionInfo(int originalSeedID)
public void setSeeds(ij.process.ByteProcessor seeds)
seeds
array refers to the region.
Second index is a seeds with a region.seeds
- region seeds.toSeedImage(java.awt.Point[][], int, int)
public void setMask(ij.process.ByteProcessor mask)
mask
- Mask of the region of interest used for processing.public void setNumberOfAnimationFrames(int numberOfAnimationFrames)
numberOfAnimationFrames
- number of animation frames.public ij.process.ByteProcessor getRegionMarkers()
public ij.ImageStack getAnimationStack()
public static ij.process.ByteProcessor toSeedImage(java.awt.Point[][] seeds, int width, int height)
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.width
- width of the seed imageheight
- height of the seed imagepublic void run()
protected void initializeStructures()