pub struct Transform2D { /* private fields */ }Expand description
2D point transformation
Useful for resampling: rotating, scaling, translating, etc image tensors
Implementations§
Source§impl Transform2D
impl Transform2D
Sourcepub fn transform<B: Backend>(self, img: Tensor<B, 4>) -> Tensor<B, 4>
pub fn transform<B: Backend>(self, img: Tensor<B, 4>) -> Tensor<B, 4>
Transforms an image
img- Images tensor with shape (batch_size, channels, height, width)
§Returns
A tensor with the same as the input
Sourcepub fn composed<I: IntoIterator<Item = Self>>(transforms: I) -> Self
pub fn composed<I: IntoIterator<Item = Self>>(transforms: I) -> Self
Makes a 2d transformation composed of other transformations
Sourcepub fn rotation(theta: f32, cx: f32, cy: f32) -> Self
pub fn rotation(theta: f32, cx: f32, cy: f32) -> Self
Makes a Transform2D for rotating a tensor
theta- In radians, the rotationcx- Center of rotation, xcy- Center of rotation, y
Sourcepub fn scale(sx: f32, sy: f32, cx: f32, cy: f32) -> Self
pub fn scale(sx: f32, sy: f32, cx: f32, cy: f32) -> Self
Makes a Transform2D for scaling an image tensor
sx- Scale factor in the x directionsy- Scale factor in the y directioncx- Center of scaling, xcy- Center of scaling, y
Sourcepub fn translation(tx: f32, ty: f32) -> Self
pub fn translation(tx: f32, ty: f32) -> Self
Makes a Transform2D for translating an image tensor
tx- Translation in the x directionty- Translation in the y direction
Auto Trait Implementations§
impl Freeze for Transform2D
impl RefUnwindSafe for Transform2D
impl Send for Transform2D
impl Sync for Transform2D
impl Unpin for Transform2D
impl UnwindSafe for Transform2D
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more