Class ChamferDistanceTransform2DFloat

java.lang.Object
inra.ijpb.algo.AlgoStub
inra.ijpb.label.distmap.ChamferDistanceTransform2DFloat
All Implemented Interfaces:
Algo, ChamferDistanceTransform2D, DistanceTransform2D

public class ChamferDistanceTransform2DFloat
extends AlgoStub
implements ChamferDistanceTransform2D
Computes distance transform by propagating distances using a ChamferMask2D, and using 32-bits floating-point computation. For binary images, an equivalent algorithm exists within the inra.ijpb.binary.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
  • 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 labelImage)
    Computes the distance map of the distance to the nearest pixel with a different value.
    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

      public ChamferDistanceTransform2DFloat​(ChamferMask2D mask)
      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

      public ChamferDistanceTransform2DFloat​(ChamferMask2D mask, boolean normalize)
      Creates a new algorithm for computing distance maps based on a chamfer mask.
      Parameters:
      mask - the chamfer mask to use for propagating distances
      normalize - whether distance map should be normalized by the weight associated to orthogonal shifts
  • Method Details

    • mask

      public ChamferMask2D mask()
      Description copied from interface: ChamferDistanceTransform2D
      Return the chamfer mask used by this distance transform algorithm.
      Specified by:
      mask in interface ChamferDistanceTransform2D
      Returns:
      the chamfer mask used by this distance transform algorithm.
    • distanceMap

      public ij.process.FloatProcessor distanceMap​(ij.process.ImageProcessor labelImage)
      Computes the distance map of the distance to the nearest pixel with a different value. The function returns a new short processor the same size as the input, with values greater or equal to zero.
      Specified by:
      distanceMap in interface DistanceTransform2D
      Parameters:
      labelImage - a label image with black pixels (0) as foreground
      Returns:
      a new instance of FloatProcessor containing:
      • 0 for each background pixel
      • the (strictly positive) distance to the nearest background pixel otherwise