pub enum Norm {
L1,
L2,
LInf,
}Expand description
How to measure distance between coordinates.
See distance_transform for examples.
Variants§
L1
d((x1, y1), (x2, y2)) = abs(x1 - x2) + abs(y1 - y2)
Also known as the Manhattan or city block norm.
L2
d((x1, y1), (x2, y2)) = sqrt((x1 - x2)^2 + (y1 - y2)^2)
Also known as the Euclidean norm.
Note that both distance_transform and the functions in the morphology
module represent distances as integer values, so cannot accurately represent L2 norms. Instead,
these functions approximate the L2 norm by taking the ceiling of the true value. If you want accurate
distances then use euclidean_squared_distance_transform instead, which returns floating point values.
LInf
d((x1, y1), (x2, y2)) = max(abs(x1 - x2), abs(y1 - y2))
Also known as the chessboard norm.
Trait Implementations§
impl Copy for Norm
impl Eq for Norm
impl StructuralPartialEq for Norm
Auto Trait Implementations§
impl Freeze for Norm
impl RefUnwindSafe for Norm
impl Send for Norm
impl Sync for Norm
impl Unpin for Norm
impl UnsafeUnpin for Norm
impl UnwindSafe for Norm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.