inra.ijpb.binary.distmap

## Class DistanceTransform5x5Float

• All Implemented Interfaces:
Algo, DistanceTransform

```public class DistanceTransform5x5Float
extends AlgoStub
implements DistanceTransform```

Computes Chamfer distances in a 5x5 neighborhood using a FloatProcessor object for storing result.

Uses 5x5 chamfer map, with two passes (one forward, one backward). Three different weights are provided for orthogonal, diagonal, and "chess-knight" moves. Weights equal to (5,7,11) usually give nice results.

Example of use:

``````float[] floatWeights = ChamferWeights.CHESSKNIGHT.getFloatWeights();
boolean normalize = true;
DistanceTransform dt = new DistanceTransform5x5Float(floatWeights, normalize);
ImageProcessor result = dt.distanceMap(inputImage);
// or:
ImagePlus resultPlus = BinaryImages.distanceMap(imagePlus, floatWeights, normalize);
``````
Author:
David Legland
`BinaryImages.distanceMap(ImageProcessor, float[], boolean)`, `DistanceTransform5x5Short`, `DistanceTransform`
• ### Constructor Summary

Constructors
Constructor and Description
`DistanceTransform5x5Float()`
Default constructor with predefined chamfer weights.
`DistanceTransform5x5Float(float[] weights)`
Default constructor that specifies the chamfer weights.
```DistanceTransform5x5Float(float[] weights, boolean normalize)```
Constructor specifying the chamfer weights and the optional normalization.
• ### Method Summary

Methods
Modifier and Type Method and Description
`ij.process.FloatProcessor` `distanceMap(ij.process.ImageProcessor image)`
Computes the distance map of the distance to the nearest boundary pixel.
• ### 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 Detail

• #### DistanceTransform5x5Float

`public DistanceTransform5x5Float()`
Default constructor with predefined chamfer weights.
• #### DistanceTransform5x5Float

`public DistanceTransform5x5Float(float[] weights)`
Default constructor that specifies the chamfer weights.
Parameters:
`weights` - an array of two weights for orthogonal and diagonal directions
• #### DistanceTransform5x5Float

```public DistanceTransform5x5Float(float[] weights,
boolean normalize)```
Constructor specifying the chamfer weights and the optional normalization.
Parameters:
`weights` - an array of two weights for orthogonal and diagonal directions
`normalize` - flag indicating whether the final distance map should be normalized by the first weight
• ### Method Detail

• #### distanceMap

`public ij.process.FloatProcessor distanceMap(ij.process.ImageProcessor image)`
Computes the distance map of the distance to the nearest boundary pixel. The function returns a new float processor the same size as the input, with values greater or equal to zero.
Specified by:
`distanceMap` in interface `DistanceTransform`
Parameters:
`image` - a binary image with white pixels (255) as foreground
Returns:
a new instance of FloatProcessor containing:
• 0 for each background pixel
• the distance to the nearest background pixel otherwise