Package inra.ijpb.binary.distmap
Class ChamferDistanceTransform2DFloat
java.lang.Object
inra.ijpb.algo.AlgoStub
inra.ijpb.binary.distmap.ChamferDistanceTransform2DFloat
- All Implemented Interfaces:
Algo
,ChamferDistanceTransform2D
,DistanceTransform
public class ChamferDistanceTransform2DFloat extends AlgoStub implements ChamferDistanceTransform2D
Computes distance transform on binary images by propagating distances using a
ChamferMask2D, and using 32-bits floating-point computation.
For label maps, an equivalent algorithm exists within the
inra.ijpb.label.distmap package.
Example of use:
ChamferMask2D mask = ChamferMask2D.BORGEFORS();
boolean normalize = true;
DistanceTransform dt = new ChamferDistanceTransform2DFloat(mask, normalize);
ImageProcessor result = dt.distanceMap(inputImage);
- Author:
- David Legland
- See Also:
ChamferDistanceTransform2DShort
,ChamferDistanceTransform2DFloat
-
Constructor Summary
Constructors Constructor Description ChamferDistanceTransform2DFloat(ChamferMask2D mask)
Creates a new algorithm for computing distance maps based on a chamfer mask.ChamferDistanceTransform2DFloat(ChamferMask2D mask, boolean normalize)
Creates a new algorithm for computing distance maps based on a chamfer mask. -
Method Summary
Modifier and Type Method Description ij.process.FloatProcessor
distanceMap(ij.process.ImageProcessor binaryImage)
Computes the distance map of the distance to the nearest background pixel.ChamferMask2D
mask()
Return the chamfer mask used by this distance transform algorithm.Methods inherited from class inra.ijpb.algo.AlgoStub
addAlgoListener, removeAlgoListener
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface inra.ijpb.algo.Algo
addAlgoListener, removeAlgoListener
-
Constructor Details
-
ChamferDistanceTransform2DFloat
Creates a new algorithm for computing distance maps based on a chamfer mask. The result is normalized by dividing by the weight for orthogonal shifts.- Parameters:
mask
- the chamfer mask to use for propagating distances
-
ChamferDistanceTransform2DFloat
Creates a new algorithm for computing distance maps based on a chamfer mask.- Parameters:
mask
- the chamfer mask to use for propagating distancesnormalize
- whether distance map should be normalized by the weight associated to orthogonal shifts
-
-
Method Details
-
mask
Description copied from interface:ChamferDistanceTransform2D
Return the chamfer mask used by this distance transform algorithm.- Specified by:
mask
in interfaceChamferDistanceTransform2D
- Returns:
- the chamfer mask used by this distance transform algorithm.
-
distanceMap
public ij.process.FloatProcessor distanceMap(ij.process.ImageProcessor binaryImage)Computes the distance map of the distance to the nearest background pixel. The function returns a new instance ofFloatProcessor
the same size as the input, with values greater or equal to zero.- Specified by:
distanceMap
in interfaceDistanceTransform
- Parameters:
binaryImage
- a binary image with black pixels (0) as background- Returns:
- a new instance of FloatProcessor containing:
- 0 for each background pixel
- the (strictly positive) distance to the nearest background pixel otherwise
-