pub struct Projection { /* private fields */ }
Expand description
A 2d projective transformation, stored as a row major 3x3 matrix.
Transformations combine by pre-multiplication, i.e. applying P * Q
is equivalent to
applying Q
and then applying P
. For example, the following defines a rotation
about the point (320.0, 240.0).
use imageproc::geometric_transformations::*;
use std::f32::consts::PI;
let (cx, cy) = (320.0, 240.0);
let c_rotation = Projection::translate(cx, cy)
* Projection::rotate(PI / 6.0)
* Projection::translate(-cx, -cy);
See ./examples/projection.rs for more examples.
Implementations§
Source§impl Projection
impl Projection
Sourcepub fn from_matrix(transform: [f32; 9]) -> Option<Projection>
pub fn from_matrix(transform: [f32; 9]) -> Option<Projection>
Creates a 2d projective transform from a row-major 3x3 matrix in homogeneous coordinates.
Returns None
if the matrix is not invertible.
Sourcepub fn and_then(self, other: Projection) -> Projection
pub fn and_then(self, other: Projection) -> Projection
Combine the transformation with another one. The resulting transformation is equivalent to
applying this transformation followed by the other
transformation.
Sourcepub fn translate(tx: f32, ty: f32) -> Projection
pub fn translate(tx: f32, ty: f32) -> Projection
A translation by (tx, ty).
Sourcepub fn rotate(theta: f32) -> Projection
pub fn rotate(theta: f32) -> Projection
A clockwise rotation around the top-left corner of the image by theta radians.
Sourcepub fn scale(sx: f32, sy: f32) -> Projection
pub fn scale(sx: f32, sy: f32) -> Projection
An anisotropic scaling (sx, sy).
Note that the warp
function does not change the size of the input image.
If you want to resize an image then use the imageops
module in the image
crate.
Sourcepub fn invert(self) -> Projection
pub fn invert(self) -> Projection
Inverts the transformation.
Sourcepub fn from_control_points(
from: [(f32, f32); 4],
to: [(f32, f32); 4],
) -> Option<Projection>
pub fn from_control_points( from: [(f32, f32); 4], to: [(f32, f32); 4], ) -> Option<Projection>
Calculates a projection from a set of four control point pairs.
Trait Implementations§
Source§impl Clone for Projection
impl Clone for Projection
Source§fn clone(&self) -> Projection
fn clone(&self) -> Projection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Projection
impl Debug for Projection
Source§impl<'a, 'b> Mul<&'b Projection> for &'a Projection
impl<'a, 'b> Mul<&'b Projection> for &'a Projection
Source§type Output = Projection
type Output = Projection
*
operator.Source§fn mul(self, rhs: &Projection) -> Projection
fn mul(self, rhs: &Projection) -> Projection
*
operation. Read moreSource§impl Mul for Projection
impl Mul for Projection
Source§type Output = Projection
type Output = Projection
*
operator.Source§fn mul(self, rhs: Projection) -> Projection
fn mul(self, rhs: Projection) -> Projection
*
operation. Read moreimpl Copy for Projection
Auto Trait Implementations§
impl Freeze for Projection
impl RefUnwindSafe for Projection
impl Send for Projection
impl Sync for Projection
impl Unpin for Projection
impl UnwindSafe for Projection
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
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
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.