Class ChamferMask2D

java.lang.Object
inra.ijpb.binary.distmap.ChamferMask2D
Direct Known Subclasses:
ChamferMask2DW2, ChamferMask2DW2Float, ChamferMask2DW3, ChamferMask2DW4

public abstract class ChamferMask2D
extends java.lang.Object
Chamfer masks defines a series of weights associated to neighbors of current pixels. The interface declares methods to access forward and backward offsets, used in classical two-passes algorithms. The weights may be defined either as integers or as floating point values.
Author:
dlegland
See Also:
ChamferMask3D, ChamferDistanceTransform2D
  • Field Details

    • CHESSBOARD

      public static final ChamferMask2D CHESSBOARD
      Use weight equal to 1 for all neighbors.
    • CITY_BLOCK

      public static final ChamferMask2D CITY_BLOCK
      Use weights 1 for orthogonal neighbors and 2 for diagonal neighbors, and 3 for cube-diagonals.
    • QUASI_EUCLIDEAN

      public static final ChamferMask2D QUASI_EUCLIDEAN
      Use weights 1 for orthogonal neighbors and sqrt(2) for diagonal neighbors. Integer weights are 10 and 14.
    • BORGEFORS

      public static final ChamferMask2D BORGEFORS
      Use weights 3 for orthogonal neighbors and 4 for diagonal neighbors (best approximation for 3-by-3 masks).
    • CHESSKNIGHT

      public static final ChamferMask2D CHESSKNIGHT
      Use weights 5 for orthogonal neighbors, 7 for diagonal neighbors, and 11 for chess-knight moves (recommended approximation for 5-by-5 masks).
    • VERWER

      public static final ChamferMask2D VERWER
      Chamfer mask in the 7-by-7 neighborhood defined using four weights. Weights are 12, 17, 27, and 38. The "sixth" is approximated by 17+27=44, very close from the value proposed by Borgefors (1986).
  • Constructor Details

    • ChamferMask2D

      public ChamferMask2D()
  • Method Details

    • fromWeights

      public static final ChamferMask2D fromWeights​(int[] weights)
      Creates a new Chamfer mask from a list of weights. The size of the chamfer mask depends on the length of the array:
      • single element: chamfer mask is 3-by-3, the element value corresponds to the weight of orthogonal offsets
      • two elements: chamfer mask is 3-by-3, the second element corresponds to the weight of diagonal offsets
      • three elements: chamfer mask is 5-by-5, the third element corresponds to the weight of chess-knight move offsets
      Parameters:
      weights - the list of weights used for building the chamfer mask
      Returns:
      the chamfer mask corresponding to the weights
    • fromWeights

      public static final ChamferMask2D fromWeights​(short[] weights)
      Creates a new Chamfer mask from a list of weights. The size of the chamfer mask depends on the length of the array:
      • single element: chamfer mask is 3-by-3, the element value corresponds to the weight of orthogonal offsets
      • two elements: chamfer mask is 3-by-3, the second element corresponds to the weight of diagonal offsets
      • three elements: chamfer mask is 5-by-5, the third element corresponds to the weight of chess-knight move offsets
      Parameters:
      weights - the list of weights used for building the chamfer mask
      Returns:
      the chamfer mask corresponding to the weights
    • fromWeights

      public static final ChamferMask2D fromWeights​(float[] weights)
      Creates a new Chamfer mask from a list of weights. The size of the chamfer mask depends on the length of the array:
      • single element: chamfer mask is 3-by-3, the element value corresponds to the weight of orthogonal offsets
      • two elements: chamfer mask is 3-by-3, the second element corresponds to the weight of diagonal offsets
      • three elements: chamfer mask is 5-by-5, the third element corresponds to the weight of chess-knight move offsets
      Parameters:
      weights - the list of weights used for building the chamfer mask
      Returns:
      the chamfer mask corresponding to the weights
    • getOffsets

      public java.util.Collection<ChamferMask2D.ShortOffset> getOffsets()
      Returns:
      the whole collection of offsets defined by this ChamferMask2D.
    • getFloatOffsets

      public java.util.Collection<ChamferMask2D.FloatOffset> getFloatOffsets()
      Returns:
      the whole collection of offsets using floating-point weights defined by this ChamferMask2D.
    • getForwardOffsets

      public abstract java.util.Collection<ChamferMask2D.ShortOffset> getForwardOffsets()
      Returns:
      the set of offsets defined by this ChamferMask2D for forward iteration using integer weights.
    • getBackwardOffsets

      public abstract java.util.Collection<ChamferMask2D.ShortOffset> getBackwardOffsets()
      Returns:
      the set of offsets defined by this ChamferMask2D for backward iteration using integer weights.
    • getForwardFloatOffsets

      public java.util.Collection<ChamferMask2D.FloatOffset> getForwardFloatOffsets()
      Returns:
      the set of offsets defined by this ChamferMask2D for forward iteration using floating-point weights.
    • getBackwardFloatOffsets

      public java.util.Collection<ChamferMask2D.FloatOffset> getBackwardFloatOffsets()
      Returns:
      the set of offsets defined by this ChamferMask2D for backward iteration using floating-point weights.
    • getNormalizationWeight

      public double getNormalizationWeight()
      Returns:
      the weight associated to orthogonal offsets, that can be used to normalize the distance map.
    • getShortNormalizationWeight

      public abstract short getShortNormalizationWeight()
      Returns:
      the weight associated to orthogonal offsets, that can be used to normalize the distance map.