public abstract class SnakeOptimizer extends MTBOperatorControllable
This class defines a generic interface for segmenting contours in an image based on parametric active contour models, i.e. snakes. It supports thread-based optimization and interaction with a graphical user interface.
Modifier and Type | Class and Description |
---|---|
static class |
SnakeOptimizer.Snake_status
Indicates the current (internal) state of the snake calculations.
|
de.unihalle.informatik.Alida.operator.ALDOperatorControllable.OperatorControlStatus, de.unihalle.informatik.Alida.operator.ALDOperatorControllable.OperatorControlStatusHandle, de.unihalle.informatik.Alida.operator.ALDOperatorControllable.OperatorExecutionStatus
Modifier and Type | Field and Description |
---|---|
protected boolean |
counterClockwiseSnakePointOrderRequested
Flag to indicate if snakes are required to be sorted counter-clockwise.
|
protected MTBTableModel |
energyData |
protected boolean[][] |
excludeMask
Mask to exclude image pixels from calculations.
|
protected int |
iChannels
Image channels.
|
protected int |
iHeight
Image height.
|
protected MTBImage |
inImg
Input image to be segmented.
|
protected MTBPolygon2DSet |
initialSnakes
Set of initial snake contours.
|
protected Vector<MTBPolygon2DSet> |
intermediateResults
Set of intermediate segmentation results, required for stack generation.
|
protected int |
itCounter
Iteration counter.
|
protected int |
iWidth
Image width.
|
protected MTBImageRGB |
outIntermediateResultsStack
Image stack with intermediate result images.
|
protected int |
outIntermediateResultsStackInterval
Interval for saving intermediate results in stack.
|
protected Boolean |
outIntermediateResultsStackWanted
Flag to request a stack of intermediate result images.
|
protected MTBPolygon2DSet |
outSnakes
Result contours.
|
protected MTBImageRGB |
outSnakesImg
Image with final snake contours overlayed.
|
protected Boolean |
sampleEnergyData |
protected Boolean |
saveIntermediateResults
Flag to enable/disable saving of intermediate results.
|
protected de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
saveIntermediateResultsPath
Path to where intermediate results should be stored.
|
protected Boolean |
showIntermediateResults
Flag to enable/disable showing of intermediate results.
|
protected int |
snakeNum
Number of snakes currently managed.
|
Constructor and Description |
---|
SnakeOptimizer()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
abstract SnakeOptimizer |
clone() |
protected abstract void |
closeWindows()
Close all windows openened by this operator (for clean-up).
|
void |
disableSaveIntermediateResults()
Deactivates writing of intermediate results.
|
void |
disableShowIntermediateResults()
Deactivates display of intermediate results.
|
protected abstract SnakeOptimizer.Snake_status |
doIteration()
Here the main work should be done.
|
void |
enableSaveIntermediateResults()
Activates writing of intermediate results to disc.
|
void |
enableShowIntermediateResults()
Activates display of intermediate results.
|
private void |
generateStackWithIntermediateResults()
Generates a stack with intermediate results.
|
abstract MTBPolygon2DSet |
getCurrentSnakes()
Returns a copy of the current snake(s).
|
boolean[][] |
getExcludeMask()
Returns the current exclude mask.
|
MTBPolygon2DSet |
getInitialSnakes()
Returns initial snake.
|
MTBImage |
getInputImage()
Returns input image.
|
int |
getIterationCount()
Returns the current iteration count.
|
MTBImageRGB |
getResultSnakeImage()
Returns image with snakes contours.
|
MTBPolygon2DSet |
getResultSnakes()
Returns the set of result snakes.
|
int |
getSnakeNumber()
Returns the number of snakes currently managed.
|
MTBImageRGB |
getStackWithIntermediateResults()
Returns a stack with intermediate segmentation results.
|
abstract MTBImage |
getWorkingImage()
Returns working image.
|
protected abstract void |
initOptimizer()
Initializes the optimizer.
|
protected void |
operate() |
private void |
plotSnakesToImage()
Returns overlay of output snakes onto current input image.
|
private static MTBImageRGB |
plotSnakesToImage(MTBPolygon2DSet polyset,
MTBImage image,
int[] colors)
Returns overlay of given snakes onto given image.
|
abstract void |
printParams()
Print current parameter settings to standard output device.
|
protected Object |
readResolve()
Init function for deserialized objects.
|
protected abstract void |
saveSnake()
Save intermediate results.
|
void |
setExcludeMask(boolean[][] mask)
Set exclude mask.
|
void |
setInitialSnakes(MTBPolygon2DSet inS)
Specify initial snakes.
|
void |
setInputImage(MTBImage img)
Specify an input image for the segmentation.
|
void |
setIntermediateResultPath(String path)
Set path for intermediate results.
|
protected abstract void |
showSnake()
Display current result contour by overlaying the current snake result
onto the input image.
|
boolean |
supportsStepWiseExecution() |
String |
toString() |
void |
validateCustom() |
void |
wantStackWithIntermediateResults(boolean flag)
Flag for turning on/off generation of stack with intermediate results.
|
addALDConfigurationEventListener, addALDControlEventListener, fireALDConfigurationEvent, fireALDControlEvent, getControlStatus, getControlStatusHandle, getExecutionStatus, handleALDConfigurationEvent, handleALDControlEvent, removeALDConfigurationEventListener, removeALDControlEventListener, setControlStatus, setNotifyRecursiveFlag
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, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Input Image", mode=STANDARD, direction=IN, required=true, description="Input Image.", dataIOOrder=0) protected transient MTBImage inImg
@Parameter(label="Initial Snake(s)", mode=STANDARD, direction=IN, required=true, description="Initial snakes.", dataIOOrder=1) protected MTBPolygon2DSet initialSnakes
@Parameter(label="outSnakes", direction=OUT, description="Final snake(s).") protected transient MTBPolygon2DSet outSnakes
@Parameter(label="Snake Plot", direction=OUT, description="Overlay with final snake(s).") protected transient MTBImageRGB outSnakesImg
@Parameter(label="Show Intermediate Results", mode=STANDARD, direction=IN, dataIOOrder=1, supplemental=true, description="Show intermediate results to user.") protected Boolean showIntermediateResults
@Parameter(label="Save Intermediate Results", mode=ADVANCED, direction=IN, dataIOOrder=2, supplemental=true, description="Save intermediate results to disc.") protected Boolean saveIntermediateResults
@Parameter(label="Save Intermediate Results To...", mode=ADVANCED, supplemental=true, direction=IN, dataIOOrder=3, description="Path for saving intermediate results.") protected de.unihalle.informatik.Alida.datatypes.ALDDirectoryString saveIntermediateResultsPath
@Parameter(label="Show Intermediate Snakes Stack", mode=ADVANCED, direction=IN, dataIOOrder=4, supplemental=true, description="Flag to show stack with intermediate segmentations.") protected Boolean outIntermediateResultsStackWanted
@Parameter(label="Saving Interval for Stack", mode=ADVANCED, direction=IN, dataIOOrder=5, supplemental=true, description="Interval for saving results to stack.") protected int outIntermediateResultsStackInterval
Note that memory issues might occur if number of iterations is high and the interval small...
@Parameter(label="Stack with Intermediate Results", direction=OUT, supplemental=true, description="Optional stack of intermediate segmentation results.") protected transient MTBImageRGB outIntermediateResultsStack
@Parameter(label="Collect energy data", supplemental=true, direction=IN, required=false, dataIOOrder=15, description="Flag for collecting energy data in each iteration.") protected Boolean sampleEnergyData
@Parameter(label="Energy data", direction=OUT, required=false, dataIOOrder=10, description="Table of iteration-wise energies.") protected transient MTBTableModel energyData
protected transient int snakeNum
protected transient int itCounter
protected transient int iWidth
protected transient int iHeight
protected transient int iChannels
protected transient boolean[][] excludeMask
protected transient boolean counterClockwiseSnakePointOrderRequested
protected transient Vector<MTBPolygon2DSet> intermediateResults
public SnakeOptimizer() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public abstract SnakeOptimizer clone()
public void validateCustom() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
validateCustom
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public boolean supportsStepWiseExecution()
supportsStepWiseExecution
in class de.unihalle.informatik.Alida.operator.ALDOperatorControllable
protected Object readResolve()
This function is called on an instance of this class being deserialized from file, prior to handing the instance over to the user. It takes care of a proper initialization of transient member variables as they are not initialized to the default values during deserialization.
readResolve
in class de.unihalle.informatik.Alida.operator.ALDOperator
protected abstract void initOptimizer() throws MTBSnakeException
Needs to be implemented by any derived class. This routine is automatically called on invoking the local operate routine.
MTBSnakeException
protected abstract SnakeOptimizer.Snake_status doIteration() throws MTBException
MTBException
protected abstract void showSnake()
protected abstract void closeWindows()
protected abstract void saveSnake()
public abstract MTBPolygon2DSet getCurrentSnakes()
If the optimizer deals with a single snake, the set contains only a single snake polygon.
public abstract void printParams()
public final int getIterationCount()
public final void setInputImage(MTBImage img)
img
- Input image.public final void setInitialSnakes(MTBPolygon2DSet inS)
inS
- Initial snakes.public final MTBImage getInputImage()
public abstract MTBImage getWorkingImage()
Usually this will be the input image, however, e.g. in case of image normalization being applied the normalized image will be returned.
public final MTBPolygon2DSet getInitialSnakes()
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public MTBImageRGB getResultSnakeImage()
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public final int getSnakeNumber()
public final MTBPolygon2DSet getResultSnakes()
public final void enableShowIntermediateResults()
public final void disableShowIntermediateResults()
public final void enableSaveIntermediateResults()
public final void disableSaveIntermediateResults()
public final void setIntermediateResultPath(String path)
public final void wantStackWithIntermediateResults(boolean flag)
public final MTBImageRGB getStackWithIntermediateResults()
public final boolean[][] getExcludeMask()
public final void setExcludeMask(boolean[][] mask)
protected final void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
private void plotSnakesToImage()
private static MTBImageRGB plotSnakesToImage(MTBPolygon2DSet polyset, MTBImage image, int[] colors)
polyset
- Set of snakes.image
- Input image where to plot the snakes.private void generateStackWithIntermediateResults()
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.