@ALDAOperator(genericExecutionMode=ALL, level=APPLICATION) public class DijkstraShortestPixelPathFinder extends MTBOperator
The image is interpreted as a graph with the pixels being the nodes and edges referring to 8-neighborhood relations. Each edge gets as weight the intensity value of the target pixel. Optionally also a power of the intensity value or its exponential function value can be used as weight. The algorithm seeks to minimize path cost, i.e., is looking for path along dark pixels.
The path is found applying the Dijkstra graph search algorithm as implemented in the JGraphT library released under GPL by Barak Naveh and contributors. For details refer to the webpage of the library, https://jgrapht.org/, and to the API documentation of the Dijkstra class.
Modifier and Type | Class and Description |
---|---|
protected class |
DijkstraShortestPixelPathFinder.GraphNode
Local class to represent the nodes of the graph.
|
static class |
DijkstraShortestPixelPathFinder.WeightModel
Modes how to set the weights.
|
Modifier and Type | Field and Description |
---|---|
protected Point2D.Double |
endPoint
End pixel of the path.
|
protected MTBImage |
inImg
Input gray-scale image.
|
protected boolean |
invertPixelValues
If true image values are inverted, i.e., the algorithm seeks to find a
path along bright pixels.
|
protected double |
nodeThreshold
Threshold for nodes to be included, nodes with an intensity above
the threshold are removed from the graph.
|
protected double |
resultCosts
Costs of the result path.
|
protected MTBImageRGB |
resultImg
Result image with path overlay, start pixel in green, end pixel in blue.
|
protected Vector<Point2D.Double> |
resultPath
Result path represented as point list.
|
protected Point2D.Double |
startPoint
Start pixel of the path.
|
protected DijkstraShortestPixelPathFinder.WeightModel |
weightModel
Model for the edge weights.
|
private double |
workImgMaxVal
Maximum intensity value in working image, i.e. after potential inversion
of image intensity values.
|
Constructor and Description |
---|
DijkstraShortestPixelPathFinder()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
getResultCosts()
Returns the costs of the shortest path.
|
MTBImageRGB |
getResultImage()
Returns the result image with path overlay.
|
Vector<Point2D.Double> |
getResultPath()
Returns the extracted shortest path as point list.
|
private double |
getWeight(double v1,
double v2)
Return edge weight for edge between given nodes.
|
protected void |
operate() |
void |
setEndPixel(Point2D.Double ep)
Specify end pixel of path.
|
void |
setInputImage(MTBImage img)
Set input image to process.
|
void |
setInvertPixelValues(boolean b)
Enable/disable pixel values invertion.
|
void |
setNodeThreshold(double t)
Set threshold for filtering nodes.
|
void |
setStartPixel(Point2D.Double sp)
Specify start pixel of path.
|
void |
setWeightModel(DijkstraShortestPixelPathFinder.WeightModel w)
Select model for choosing edge weights.
|
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="Input image.") protected transient MTBImage inImg
By default, intensity values are directly interpreted as costs, i.e.,
the algorithm is searching for paths along dark pixels. If this is not
intended, select option. invertPixelValues
to invert values.
@Parameter(label="Invert Pixel Values?", required=true, dataIOOrder=-1, direction=IN, description="Invert pixel values, i.e., favor bright pixels.") protected boolean invertPixelValues
@Parameter(label="Weight Model", required=true, dataIOOrder=0, direction=IN, description="Edge weight model.") protected DijkstraShortestPixelPathFinder.WeightModel weightModel
@Parameter(label="Start Pixel", required=true, dataIOOrder=1, direction=IN, description="Start pixel.") protected Point2D.Double startPoint
@Parameter(label="End Pixel", required=true, dataIOOrder=2, direction=IN, description="Result image.") protected Point2D.Double endPoint
@Parameter(label="Node Threshold", required=true, dataIOOrder=3, direction=IN, description="Only intensities below threshold (or above if inverted mode is active) are considered.") protected double nodeThreshold
By default the threshold is Double.MAX_VALUE and all nodes are considered. Omitting nodes (and corresponding edges) has a positive effect on runtime.
@Parameter(label="Result image", direction=OUT, dataIOOrder=1, description="Result image with path overlay.") protected transient MTBImageRGB resultImg
@Parameter(label="Result path", direction=OUT, dataIOOrder=2, description="Result path represented as point list.") protected Vector<Point2D.Double> resultPath
@Parameter(label="Result costs", direction=OUT, dataIOOrder=3, description="Costs of result path.") protected double resultCosts
private double workImgMaxVal
public DijkstraShortestPixelPathFinder() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.public void setInputImage(MTBImage img)
img
- Input image to process.public void setInvertPixelValues(boolean b)
b
- If true, pixel intensities are inverted.public void setWeightModel(DijkstraShortestPixelPathFinder.WeightModel w)
w
- Model to apply.public void setStartPixel(Point2D.Double sp)
sp
- Start pixel.public void setEndPixel(Point2D.Double ep)
ep
- End pixel.public void setNodeThreshold(double t)
t
- Threshold to apply.public MTBImageRGB getResultImage()
public Vector<Point2D.Double> getResultPath()
public double getResultCosts()
protected void operate()
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
private double getWeight(double v1, double v2)
We assume here that small intensity values of the target node are good, i.e., the edge towards the pixel should ge a small weight.
v1
- Source node of edge.v2
- Target node of edge.Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.