Package inra.ijpb.binary.distmap
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classChamferMask2D.FloatOffsetThe shift to a neighbor of a reference pixel, as a pair (dx,dy), and the associated weights given as a float.static classChamferMask2D.ShortOffsetThe shift to a neighbor of a reference pixel, as a pair (dx,dy), and the associated weights given as a short. -
Field Summary
Fields Modifier and Type Field Description static ChamferMask2DBORGEFORSUse weights 3 for orthogonal neighbors and 4 for diagonal neighbors (best approximation for 3-by-3 masks).static ChamferMask2DCHESSBOARDUse weight equal to 1 for all neighbors.static ChamferMask2DCHESSKNIGHTUse weights 5 for orthogonal neighbors, 7 for diagonal neighbors, and 11 for chess-knight moves (recommended approximation for 5-by-5 masks).static ChamferMask2DCITY_BLOCKUse weights 1 for orthogonal neighbors and 2 for diagonal neighbors, and 3 for cube-diagonals.static ChamferMask2DQUASI_EUCLIDEANUse weights 1 for orthogonal neighbors and sqrt(2) for diagonal neighbors.static ChamferMask2DVERWERChamfer mask in the 7-by-7 neighborhood defined using four weights. -
Constructor Summary
Constructors Constructor Description ChamferMask2D() -
Method Summary
Modifier and Type Method Description static ChamferMask2DfromWeights(float[] weights)Creates a new Chamfer mask from a list of weights.static ChamferMask2DfromWeights(int[] weights)Creates a new Chamfer mask from a list of weights.static ChamferMask2DfromWeights(short[] weights)Creates a new Chamfer mask from a list of weights.java.util.Collection<ChamferMask2D.FloatOffset>getBackwardFloatOffsets()abstract java.util.Collection<ChamferMask2D.ShortOffset>getBackwardOffsets()java.util.Collection<ChamferMask2D.FloatOffset>getFloatOffsets()java.util.Collection<ChamferMask2D.FloatOffset>getForwardFloatOffsets()abstract java.util.Collection<ChamferMask2D.ShortOffset>getForwardOffsets()doublegetNormalizationWeight()java.util.Collection<ChamferMask2D.ShortOffset>getOffsets()abstract shortgetShortNormalizationWeight()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
CHESSBOARD
Use weight equal to 1 for all neighbors. -
CITY_BLOCK
Use weights 1 for orthogonal neighbors and 2 for diagonal neighbors, and 3 for cube-diagonals. -
QUASI_EUCLIDEAN
Use weights 1 for orthogonal neighbors and sqrt(2) for diagonal neighbors. Integer weights are 10 and 14. -
BORGEFORS
Use weights 3 for orthogonal neighbors and 4 for diagonal neighbors (best approximation for 3-by-3 masks). -
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
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
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
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
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
- Returns:
- the whole collection of offsets defined by this ChamferMask2D.
-
getFloatOffsets
- Returns:
- the whole collection of offsets using floating-point weights defined by this ChamferMask2D.
-
getForwardOffsets
- Returns:
- the set of offsets defined by this ChamferMask2D for forward iteration using integer weights.
-
getBackwardOffsets
- Returns:
- the set of offsets defined by this ChamferMask2D for backward iteration using integer weights.
-
getForwardFloatOffsets
- Returns:
- the set of offsets defined by this ChamferMask2D for forward iteration using floating-point weights.
-
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.
-