Metric class
Represents a metric to be used to create a dip::NeighborList
Contents
A metric describes the distance between a pixel and its neighbors. It also describes implicitly the size of a neighborhood, as the minimum neighborhood size required to propagate distances in the given metric.
Constructors, destructors, assignment and conversion operators
 Metric(dip::Metric::TypeCode type = TypeCode::CONNECTED, dip::uint param = 1)
 The default metric is the city distance (L^{1} metric).
 Metric(dip::String const& type, dip::uint param = 1, dip::PixelSize const& pixelSize = {})
 A string implicitly converts to a metric.
 Metric(dip::Image const& image)
 An image implicitly converts to a metric.
Enums
Functions
 auto Type() const > dip::Metric::TypeCode
 Retrieve the type code.
 auto Param() const > dip::uint
 Retrieve the parameter.
 auto Image() const > dip::Image const&
 Retrieve the image.
 auto PixelSize() const > dip::FloatArray const&
 Retrieve the pixel size array. Note that this could be an empty array, or have any number of elements.
 auto HasPixelSize() const > bool
 Returns true if the pixel size array is set (a nonempty array).
 void SetPixelSize(dip::PixelSize const& pixelSize)
 Sets the pixel size associated to the
Metric
. Will overwrite an earlier defined pixel size. Note that when theMetric
is defined by an image, the pixel size is ignored.
Enum documentation
Function documentation
Metric(dip::String const& type, dip::uint param = 1, dip::PixelSize const& pixelSize = {})
A string implicitly converts to a metric.
Valid metrics are:

"connected"
: here,param
is the connectivity, see Connectivity for information on the connectivity parameter. A value of 1 corresponds to the cityblock metric; a value of 0 indicates a connectivity equal to the image dimensionality, and corresponds to the chessboard metric. 
"chamfer"
: a chamfer metric.param
indicates the neighborhood size: A value of 1 gives a full 3x3 neighborhood (in 2D, or 3x3x3 in 3D, etc). A value of 2 gives the 5x5 chamfer neighborhood (i.e. the 3x3 neighborhood plus the pixels that are night’s move away from the origin). 
"city"
: L^{1} metric, equivalent to"connected"
withparam=1
. 
"chess"
: L^{∞} metric, equivalent to"connected"
withparam
= dimensionality. 
"4connected"
is equivalent to"connected"
withparam=1
. 
"8connected"
is equivalent to"connected"
withparam=2
. 
"6connected"
is equivalent to"connected"
withparam=1
. 
"18connected"
is equivalent to"connected"
withparam=2
. 
"28connected"
is equivalent to"connected"
withparam=3
.
The "chamfer"
metrics (with param
set to 1 or 2) for 2 and 3dimensional images use optimized weights as
distances that lead to unbiased distance transforms (Verwer, 1991). All other metrics use Euclidean
distances.
The pixelSize
parameter, if given, causes the neighbor’s distances to be scaled by the
pixel size. The units must be identical in all dimensions, and only the magnitude is used.
Metric(dip::Image const& image)
An image implicitly converts to a metric.
The image’s grey values are the metric distances. The image must have an odd size along each dimension, and be scalar and realvalued. The pixel in the middle of the image is the origin, and must have a value of 0.
For example, this 3 by 3 image:
++++  0  2  0  ++++  1  0  1  ++++  0  2  0  ++++
is equivalent to
dip::Metric( "city", 0, dip::PixelSize{ 1, 2 } )
If the image has a pixel size set, it is ignored. The SetPixelSize
method has no effect on a Metric
defined in this way.