[][src]Struct signed_distance_field::distance_field::NormalizedDistanceField

pub struct NormalizedDistanceField<D: DistanceStorage> {
    pub width: u16,
    pub height: u16,
    pub distances: D,
    pub zero_distance: f32,
    pub former_min_distance: f32,
    pub former_max_distance: f32,
    pub distance_targets: Vec<(u16, u16)>,
}

Represents a distance field which was normalized to the range [0, 1]. Also contains information about the greatest distances of the unnormalized distance field.

Fields

width: u16height: u16distances: D

All distances are in the range of [0..1].

zero_distance: f32

In the original distance field, edges are represented by a distance of zero. Normalizing the distance field will result in edges no longer being zero. The normalized field will have edges somewhere between zero and one. This float describes the new value that edges in the normalized field have.

former_min_distance: f32

The largest distance in the image to the nearest edge outside of a shape .

former_max_distance: f32

The largest distance in the image to the nearest edge inside of a shape

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> NormalizedDistanceField<D> where
    D: DistanceStorage
[src]

pub fn normalize(distance_field: SignedDistanceField<D>) -> Option<Self>[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(
    distance_field: SignedDistanceField<D>,
    min: f32,
    max: f32
) -> Option<Self>
[src]

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 put at exactly the middle between min and max, being 0.5 if min == -max.

Also collects the former minimum and maximum distance. Returns None if the binary image did not contain any shapes.

pub fn to_u8(&self) -> Vec<u8>[src]

Convert the normalized distance to an u8 image with the range fully utilized.

pub fn to_u16(&self) -> Vec<u16>[src]

Convert the normalized distance to an u16 image with the range fully utilized.

Auto Trait Implementations

impl<D> Send for NormalizedDistanceField<D> where
    D: Send

impl<D> Sync for NormalizedDistanceField<D> where
    D: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]