[−][src]Struct signed_distance_field::distance_field::SignedDistanceField
Contains the distance field and the vector field produced by SignedDistanceField::compute
.
Can be normalized in order to convert to an image with limited range.
The type parameter D
can be used to customize the memory layout of the distance field.
The library provides default Storages for Vec<f16>
and Vec<f23>
alias F16DistanceStorage
and F32DistanceStorage
.
If any distance in this field is INFINITY
, no shapes were found in the binary image.
Fields
width: u16
height: u16
distances: D
A row-major image vector with for each pixel of the original image containing the distance from that pixel to the nearest edge
distance_targets: Vec<(u16, u16)>
A row-major image vector with for each pixel of the original image containing the absolute position of the nearest edge from that pixel
Methods
impl<D> SignedDistanceField<D> where
D: DistanceStorage,
[src]
D: DistanceStorage,
pub fn compute(
binary_image: &impl BinaryImage
) -> Self
[src]
binary_image: &impl BinaryImage
) -> Self
Approximates the signed distance field of the specified image. The algorithm used is based on the paper "The dead reckoning signed distance transform" by George J. Grevara, 2004.
pub fn get_distance(&self, x: u16, y: u16) -> f32
[src]
Returns the distance of the specified pixel to the nearest edge in the original image.
pub fn get_distance_target(&self, x: u16, y: u16) -> (u16, u16)
[src]
Returns the absolute index of the nearest edge to the specified pixel in the original image.
pub fn flatten_index(&self, x: u16, y: u16) -> usize
[src]
Convert x and y pixel coordinates to the corresponding one-dimensional index in a row-major image vector.
pub fn normalize_distances(self) -> Option<NormalizedDistanceField<D>>
[src]
Scales all distances such that the smallest distance is zero and the largest is one.
Also computes the former minimum and maximum distance, as well as the new edge-value.
Returns None
if the binary image did not contain any shapes.
pub fn normalize_clamped_distances(
self,
min: f32,
max: f32
) -> Option<NormalizedDistanceField<D>>
[src]
self,
min: f32,
max: f32
) -> Option<NormalizedDistanceField<D>>
Scales all distances such that the min
distances are zero and max
distances are one.
All distances smaller than min
and larger than max
will be clamped.
Edges (formerly zero-distances) will be at the center, put to 0.5
.
Also collects the former minimum and maximum distance.
Returns None
if the binary image did not contain any shapes.
Trait Implementations
impl<D: Clone + DistanceStorage> Clone for SignedDistanceField<D>
[src]
fn clone(&self) -> SignedDistanceField<D>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<D: PartialEq + DistanceStorage> PartialEq<SignedDistanceField<D>> for SignedDistanceField<D>
[src]
fn eq(&self, other: &SignedDistanceField<D>) -> bool
[src]
fn ne(&self, other: &SignedDistanceField<D>) -> bool
[src]
impl<D: Debug + DistanceStorage> Debug for SignedDistanceField<D>
[src]
Auto Trait Implementations
impl<D> Send for SignedDistanceField<D> where
D: Send,
D: Send,
impl<D> Sync for SignedDistanceField<D> where
D: Sync,
D: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,