pub struct DisplacementField {
pub field: Vec<f64>,
pub dims: Vec<usize>,
pub n_components: usize,
}Expand description
A dense displacement (vector) field over a 2D or 3D domain.
For a 2D domain of shape (rows, cols) the field has shape (rows, cols, 2)
where the last dimension carries [dy, dx] displacements in pixels.
For a 3D domain (nz, ny, nx) the shape is (nz, ny, nx, 3) with [dz, dy, dx].
Fields§
§field: Vec<f64>Displacement vectors; shape [..dims.., n_components].
dims: Vec<usize>Spatial dimensions of the domain (e.g., [rows, cols] or [nz, ny, nx]).
n_components: usizeNumber of vector components (2 for 2D, 3 for 3D).
Implementations§
Source§impl DisplacementField
impl DisplacementField
Sourcepub fn zeros_2d(rows: usize, cols: usize) -> DisplacementField
pub fn zeros_2d(rows: usize, cols: usize) -> DisplacementField
Create a zero displacement field for a 2D domain.
Sourcepub fn zeros_3d(nz: usize, ny: usize, nx: usize) -> DisplacementField
pub fn zeros_3d(nz: usize, ny: usize, nx: usize) -> DisplacementField
Create a zero displacement field for a 3D domain.
Sourcepub fn num_voxels(&self) -> usize
pub fn num_voxels(&self) -> usize
Total number of spatial voxels / pixels.
Sourcepub fn get_2d(&self, r: usize, c: usize) -> Result<[f64; 2], NdimageError>
pub fn get_2d(&self, r: usize, c: usize) -> Result<[f64; 2], NdimageError>
Access the displacement vector at pixel (r, c) for a 2D field.
Returns [dy, dx].
Sourcepub fn set_2d(
&mut self,
r: usize,
c: usize,
dy: f64,
dx: f64,
) -> Result<(), NdimageError>
pub fn set_2d( &mut self, r: usize, c: usize, dy: f64, dx: f64, ) -> Result<(), NdimageError>
Set the displacement vector at pixel (r, c) for a 2D field.
Sourcepub fn get_3d(
&self,
iz: usize,
iy: usize,
ix: usize,
) -> Result<[f64; 3], NdimageError>
pub fn get_3d( &self, iz: usize, iy: usize, ix: usize, ) -> Result<[f64; 3], NdimageError>
Access the displacement vector at voxel (iz, iy, ix) for a 3D field.
Returns [dz, dy, dx].
Sourcepub fn compose_2d(
&self,
other: &DisplacementField,
) -> Result<DisplacementField, NdimageError>
pub fn compose_2d( &self, other: &DisplacementField, ) -> Result<DisplacementField, NdimageError>
Compose two displacement fields: result(x) = self(x) + other(x + self(x)).
Currently supports only 2D fields.
Sourcepub fn gaussian_smooth_2d(&mut self, sigma: f64) -> Result<(), NdimageError>
pub fn gaussian_smooth_2d(&mut self, sigma: f64) -> Result<(), NdimageError>
Apply a Gaussian smoothing kernel to the displacement field in-place.
Only 2D fields are supported. sigma is in pixels.
Sourcepub fn rms_magnitude(&self) -> f64
pub fn rms_magnitude(&self) -> f64
Root-mean-square magnitude of the displacement vectors.
Trait Implementations§
Source§impl Clone for DisplacementField
impl Clone for DisplacementField
Source§fn clone(&self) -> DisplacementField
fn clone(&self) -> DisplacementField
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DisplacementField
impl RefUnwindSafe for DisplacementField
impl Send for DisplacementField
impl Sync for DisplacementField
impl Unpin for DisplacementField
impl UnsafeUnpin for DisplacementField
impl UnwindSafe for DisplacementField
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.