@ALDAOperator(genericExecutionMode=ALL, level=APPLICATION) public class ComponentPostprocess extends MTBOperator
Thresholding algorithms yield binary images with distinct connected components of foreground pixels, i.e. regions. The routines of this operator provide functionality for post-processing such binary (unlabeled) component images. Exemplary post-processing steps might include linking/merging adjacent components or changing a component's morphological shape.
Note that the different processing modes may require different parameter settings. These settings have to be done explicitly by calling the corresponding setter-functions the class provides. If the parameters are not set by the user default values are used.
Modifier and Type | Class and Description |
---|---|
static class |
ComponentPostprocess.ProcessMode
Processing mode identifiers.
|
Modifier and Type | Field and Description |
---|---|
private double |
compactnessTreshold
Compactness threshold for components.
|
private boolean |
diagonalNeighbors
Flag for using 8-neighborhood.
|
private int |
dilateMaskSize
Mask size for topology-preserving dilation.
|
private Vector<Vector<Point2D.Double>> |
endPointHash |
private int |
height |
private MTBImage |
inImg
(Binary) Input image.
|
private int |
maxCompDist
Maximal distance of adjacent components.
|
private int |
maxCompSize
Minimal size of components in mode ERASE_SMALL_COMPS.
|
private int |
maxVoronoiExpDist
Voronoi expansion distance.
|
private int |
minCompSize
Minimal size of components in mode ERASE_SMALL_COMPS.
|
private ComponentPostprocess.ProcessMode |
processMode
Processing mode.
|
private MTBImage |
resultImg
Result image.
|
private double |
roundnessThreshold
Roundness threshold for components.
|
private int |
width |
Constructor and Description |
---|
ComponentPostprocess()
Default constructor.
|
ComponentPostprocess(MTBImage img,
ComponentPostprocess.ProcessMode pm)
Default constructor.
|
ComponentPostprocess(MTBImage img,
ComponentPostprocess.ProcessMode pm,
int _minCompSize,
int _maxCompDist,
int maxVoroExpandDist)
Deprecated.
|
ComponentPostprocess(MTBImage img,
ComponentPostprocess.ProcessMode pm,
int _minCompSize,
int _maxCompDist,
int maxVoroExpandDist,
double _roundnessThreshold)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected MTBImage |
dilateComponentsTopologyPreserving(MTBImage lImg,
int maskSize)
Perform a dilation of the given image with given masksize, but
preserve topology.
|
protected MTBImageByte |
EraseLargeComponents(MTBImageByte binIP,
int maxComponentSize)
Function to remove large components from a binary image.
|
protected MTBImageByte |
eraseNonCompactComponents(MTBImageByte binImage,
double threshold)
Function to remove all non compact/circular components of a binary image.
|
protected MTBImageByte |
EraseRoundComponents(MTBImageByte binImage,
double threshold)
Remove components with small eccentricity.
|
protected MTBImageByte |
EraseSmallComponents(MTBImageByte binIP,
int minComponentSize)
Function to remove small components from a binary image.
|
private void |
foregroundToBackground(Vector<Point2D.Double> points,
MTBImage image)
Set the pixel value containing in a
java.util.Vector
of java.awt.geom.Points2D to 0. |
double |
getCompactnessThreshold()
Returns the actual value of compactness threshold.
|
boolean |
getDiagonalNeighbors()
Get value of Parameter argument DiagonalNeighbors.
|
MTBImage |
getInputImage()
Get reference to the current input image.
|
int |
getMaximalComponentDist()
Returns the maximal component distance for linking.
|
int |
getMaximalComponentSize()
Returns the maximal valid component size for component removal.
|
int |
getMaxVoronoiExpandDist()
Returns the maximal distance of pixels considered in Voronoi expansion.
|
int |
getMinimalComponentSize()
Returns the minimal valid component size for component removal.
|
ComponentPostprocess.ProcessMode |
getProcessMode()
Get current process mode.
|
MTBImage |
getResultImage()
Get the result image after applying operator.
|
double |
getRoundnessThreshold()
Returns the currently active roundness threshold.
|
protected MTBImageByte |
LinkAdjacentComponents(MTBImageByte binIP)
Function for linking adjacent components/regions in a binary image.
|
protected MTBImageByte |
LinkAdjacentPixels(MTBImageByte binIP,
int maxDist)
Function for linking adjacent pixels in a binary image.
|
protected void |
operate() |
void |
setCompactnessThreshold(double _compactnessTrheshold)
Set the compactness threshold for eliminating non compact components.
|
void |
setDiagonalNeighbors(boolean value)
If true 8-neighborhood, i.e. diagonal neighbors, will be used in
mode 'VORONOI_EXPAND' for Voronoi dilation.
|
void |
setDilateMaskSize(int mask)
Specify mask size for topology-preserving dilation.
|
void |
setInputImage(MTBImage img)
Specify input image.
|
void |
setMaximalComponentDistance(int _maxCompDist)
Set maximal component/pixel distance for linking.
|
void |
setMaximalComponentSize(int _maxCompSize)
Set maximal component size for erasing large components.
|
void |
setMaximalVoronoiExpansionDistance(int _maxVoroExpandDist)
Set radius of dilation mask in Voronoi expansion.
|
void |
setMinimalComponentSize(int _minCompSize)
Set minimal component size for erasing small components.
|
void |
setProcessMode(ComponentPostprocess.ProcessMode pm)
Specify process mode.
|
void |
setRoundnessThreshold(double _roundnessThreshold)
Set roundness threshold for eliminating round components.
|
protected MTBImage |
VoronoiExpandComponents(MTBImage labelImg,
int maxDist)
Deprecated.
Implementation is quite slow, use method
dilateComponentsTopologyPreserving(MTBImage, int) . |
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getDocumentation, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Input Image", required=true, dataIOOrder=-10, direction=IN, description="(Binary) input image.") private transient MTBImage inImg
@Parameter(label="Process Mode", required=true, dataIOOrder=-9, direction=IN, description="Process mode.") private ComponentPostprocess.ProcessMode processMode
@Parameter(label="Min. Component Size", required=false, direction=IN, dataIOOrder=-8, description="Minimal component size, smaller ones are deleted.") private int minCompSize
@Parameter(label="Max. Component Size", required=false, direction=IN, dataIOOrder=-8, description="Maximal component size, larger ones are deleted.") private int maxCompSize
@Parameter(label="Max. Distance of Componens", required=false, direction=IN, dataIOOrder=-6, description="Maximum allowed distance of components to be linked.") private int maxCompDist
@Parameter(label="Max. Voronoi Expansion Distance", required=false, direction=IN, dataIOOrder=-4, description="Distance to which components are expanded in Voronoi expansion mode.") private int maxVoronoiExpDist
@Parameter(label="Use Diagonal Neighbors? ", required=false, direction=IN, dataIOOrder=-10, description="Flag for considering 8-neighborhood instead of 4-NB") private boolean diagonalNeighbors
@Parameter(label="Roundness Threshold", required=false, direction=IN, dataIOOrder=-2, description="Threshold for removing round components, larger values enforce greater eccentricity of surviving components.") private double roundnessThreshold
@Parameter(label="Compactness Threshold", required=false, direction=IN, dataIOOrder=-7, description="The theshold for removing noncompact components, larger values enforce more compact regions") private double compactnessTreshold
@Parameter(label="Dilate Mask Size", required=false, direction=IN, dataIOOrder=-7, description="Dilation mask size.") private int dilateMaskSize
@Parameter(label="Result Image", required=true, direction=OUT, description="Result image") private transient MTBImage resultImg
private transient int width
private transient int height
private transient Vector<Vector<Point2D.Double>> endPointHash
public ComponentPostprocess() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public ComponentPostprocess(MTBImage img, ComponentPostprocess.ProcessMode pm) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Note that parameters for the chosen processing mode have to be set explicitly. Parameters for other modes are ignored.
img
- Image to work on.pm
- Process mode of operator.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- @Deprecated public ComponentPostprocess(MTBImage img, ComponentPostprocess.ProcessMode pm, int _minCompSize, int _maxCompDist, int maxVoroExpandDist) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
img
- Image to work on.pm
- Process mode of operator._minCompSize
- Minimal region size for eliminating small comps._maxCompDist
- Maximal region distance in linking.maxVoroExpandDist
- Max. distance of pixel considered in Voronoi expansion.
Note: Depending on the process mode each time only one of the
parameters is actually in use.
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
@Deprecated public ComponentPostprocess(MTBImage img, ComponentPostprocess.ProcessMode pm, int _minCompSize, int _maxCompDist, int maxVoroExpandDist, double _roundnessThreshold) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
img
- pm
- Process mode of operator.
_minCompSize
- _maxCompDist
- maxVoroExpandDist
- _roundnessThreshold
- de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setInputImage(MTBImage img)
img
- Image to process.public void setProcessMode(ComponentPostprocess.ProcessMode pm)
pm
- Process mode of operator.public void setMinimalComponentSize(int _minCompSize)
Only used in mode 'ERASE_SMALL_COMPS'.
_minCompSize
- public void setMaximalComponentSize(int _maxCompSize)
Only used in mode 'ERASE_LARGE_COMPS'.
public void setMaximalComponentDistance(int _maxCompDist)
Only used in modes 'LINK_ADJ_COMPS' and 'LINK_ADJ_PIXELS'.
public void setMaximalVoronoiExpansionDistance(int _maxVoroExpandDist)
Only used in mode 'VORONOI_EXPAND'.
_maxVoroExpandDist
- public void setRoundnessThreshold(double _roundnessThreshold)
Only used in mode 'ERASE_ROUND_COMPS'.
_roundnessThreshold
- public void setCompactnessThreshold(double _compactnessTrheshold)
_compactnessTrheshold
- public void setDilateMaskSize(int mask)
mask
- Mask size to applypublic void setDiagonalNeighbors(boolean value)
value
- public MTBImage getInputImage()
public ComponentPostprocess.ProcessMode getProcessMode()
public int getMinimalComponentSize()
public int getMaximalComponentSize()
public int getMaximalComponentDist()
public int getMaxVoronoiExpandDist()
public boolean getDiagonalNeighbors()
public double getRoundnessThreshold()
public double getCompactnessThreshold()
public MTBImage getResultImage()
protected void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected MTBImageByte EraseSmallComponents(MTBImageByte binIP, int minComponentSize) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Small components are components that have a size below the given threshold. Suitable for noise reduction in binary images.
binIP
- binary input imageminComponentSize
- minimum size of valid componentsde.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected MTBImageByte EraseLargeComponents(MTBImageByte binIP, int maxComponentSize) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Large components are components that have a size above the given threshold.
binIP
- binary input imagemaxComponentSize
- maximum size of valid componentsde.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected MTBImageByte EraseRoundComponents(MTBImageByte binImage, double threshold) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
binImage
- Input image.threshold
- Eccentricity threshold.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected MTBImageByte eraseNonCompactComponents(MTBImageByte binImage, double threshold) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
binImage
- The input image.threshold
- The threshold of compactnessthreshold
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected MTBImageByte LinkAdjacentComponents(MTBImageByte binIP) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
This function processes a binary image with foreground objects being white. Based on an initial component labeling step and subsequent skeletonization of resulting components, adjacent components are linked by a line of width one pixel in the result image.
The criterion for two components to be adjacent is defined based on the distance of pairs of skeleton endpoints of both components. If there exists at least one pair of endpoints between two components with a distance below the given threshold, the components are linked. If there is more than one pair of such points, the pair with the smallest distance is selected to be linked to each other.
binIP
- input binary image with regionsde.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
protected MTBImageByte LinkAdjacentPixels(MTBImageByte binIP, int maxDist) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
This function processes a binary image containing only isolated pixels in the foreground. The foreground color is white. Based on the given maximal distance adjacent pixels are linked together to components. The result is comparable to a single-linkage clustering. As result an image is returned where adjacent pixels are linked to each other by a line of width one.
Note that the behaviour of the function is undefined if there are foreground objects present in the image other than single pixels!
binIP
- input binary image with regionsmaxDist
- de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
@Deprecated protected MTBImage VoronoiExpandComponents(MTBImage labelImg, int maxDist) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
dilateComponentsTopologyPreserving(MTBImage, int)
.Each component is dilated up to the maximum given pixel distance. However, the dilation is stopped immediately if its continuation would cause the component to merge with one of its neighbors.
Note that this method is not tuned for efficiency and
it is really, really slow. As an alternative you can use the
processing mode ComponentPostprocess.ProcessMode.DILATE_TOPOLOGY_PRESERVING
or the method
dilateComponentsTopologyPreserving(MTBImage, int)
,
respectively, based on a Chamfer distance transformation and
being much faster.
labelImg
- Input image.maxDist
- Size of dilation mask to apply.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.protected MTBImage dilateComponentsTopologyPreserving(MTBImage lImg, int maskSize) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
lImg
- Input label image.maskSize
- Size of dilation mask.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.private void foregroundToBackground(Vector<Point2D.Double> points, MTBImage image)
java.util.Vector
of java.awt.geom.Points2D
to 0.
This is a private helper method.
points
- image
- Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.