Struct ImageBase

Source
pub struct ImageBase<T, C>
where C: ColourModel, T: Data,
{ pub data: ArrayBase<T, Ix3>, /* private fields */ }
Expand description

Basic structure containing an image.

Fields§

§data: ArrayBase<T, Ix3>

Images are always going to be 3D to handle rows, columns and colour channels

This should allow for max compatibility with maths ops in ndarray. Caution should be taken if performing any operations that change the number of channels in an image as this may cause other functionality to perform incorrectly. Use conversions to one of the Generic colour models instead.

Implementations§

Source§

impl<T, U, C> ImageBase<U, C>
where U: Data<Elem = T>, T: Copy + Clone + FromPrimitive + Num + NumCast + PixelBound, C: ColourModel,

Source

pub fn into_type<T2>(self) -> Image<T2, C>

Converts image into a different type - doesn’t scale to new pixel bounds

Source§

impl<S, T, C> ImageBase<S, C>
where S: Data<Elem = T>, T: Clone, C: ColourModel,

Source

pub fn to_owned(&self) -> Image<T, C>

Source

pub fn from_shape_data(rows: usize, cols: usize, data: Vec<T>) -> Image<T, C>

Given the shape of the image and a data vector create an image. If the data sizes don’t match a zero filled image will be returned instead of panicking

Source§

impl<T, C> ImageBase<OwnedRepr<T>, C>
where T: Clone + Num, C: ColourModel,

Source

pub fn new(rows: usize, columns: usize) -> Self

Construct a new image filled with zeros using the given dimensions and a colour model

Source§

impl<T, U, C> ImageBase<T, C>
where T: Data<Elem = U>, C: ColourModel,

Source

pub fn from_data(data: ArrayBase<T, Ix3>) -> Self

Construct the image from a given Array3

Source

pub fn rows(&self) -> usize

Returns the number of rows in an image

Source

pub fn cols(&self) -> usize

Returns the number of channels in an image

Source

pub fn channels(&self) -> usize

Convenience method to get number of channels

Source

pub fn pixel(&self, row: usize, col: usize) -> ArrayView<'_, U, Ix1>

Get a view of all colour channels at a pixels location

Source

pub fn into_type_raw<C2>(self) -> ImageBase<T, C2>
where C2: ColourModel,

Source§

impl<T, U, C> ImageBase<T, C>
where T: DataMut<Elem = U>, C: ColourModel,

Source

pub fn pixel_mut(&mut self, row: usize, col: usize) -> ArrayViewMut<'_, U, Ix1>

Get a mutable view of a pixels colour channels given a location

Trait Implementations§

Source§

impl<T, U, C> CannyEdgeDetectorExt<T> for ImageBase<U, C>
where U: DataMut<Elem = T>, T: Copy + Clone + FromPrimitive + Real + Num + NumAssignOps, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<bool>, C>

Output type, this is different as canny outputs a binary image
Source§

fn canny_edge_detector( &self, params: CannyParameters<T>, ) -> Result<Self::Output, Error>

Run the edge detection algorithm with the given parameters. Due to Canny being specified as working on greyscale images all current implementations assume a single channel image returning an error otherwise.
Source§

impl<S, C> Clone for ImageBase<S, C>
where S: RawDataClone + Data, C: ColourModel,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
Source§

fn clone_from(&mut self, other: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, U, C> ConvolutionExt<T> for ImageBase<U, C>
where U: DataMut<Elem = T>, T: Copy + Clone + Num + NumAssignOps, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<T>, C>

Type for the output as data will have to be allocated
Source§

fn conv2d<B: Data<Elem = T>>( &self, kernel: ArrayBase<B, Ix3>, ) -> Result<Self::Output, Error>

Perform a convolution returning the resultant data applies the default padding of zero padding
Source§

fn conv2d_inplace<B: Data<Elem = T>>( &mut self, kernel: ArrayBase<B, Ix3>, ) -> Result<(), Error>

Performs the convolution inplace mutating the containers data applies the default padding of zero padding
Source§

fn conv2d_with_padding<B: Data<Elem = T>>( &self, kernel: ArrayBase<B, Ix3>, strategy: &impl PaddingStrategy<T>, ) -> Result<Self::Output, Error>

Perform a convolution returning the resultant data applies the default padding of zero padding
Source§

fn conv2d_inplace_with_padding<B: Data<Elem = T>>( &mut self, kernel: ArrayBase<B, Ix3>, strategy: &impl PaddingStrategy<T>, ) -> Result<(), Error>

Performs the convolution inplace mutating the containers data applies the default padding of zero padding
Source§

impl<T, U, C> Debug for ImageBase<U, C>
where U: Data<Elem = T>, T: Debug, C: ColourModel,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<ImageBase<T, CIELAB>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, CIELAB>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, CIELUV>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, CIELUV>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, CIEXYZ>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, CIEXYZ>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic1>> for ImageBase<T, Gray>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic1>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, CIELAB>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, CIELUV>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, CIEXYZ>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, HSI>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, HSL>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, HSV>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, RGB>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic3>> for ImageBase<T, YCrCb>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Generic4>> for ImageBase<T, RGBA>
where T: Data,

Source§

fn from(image: ImageBase<T, Generic4>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, Gray>> for ImageBase<T, Generic1>
where T: Data,

Source§

fn from(image: ImageBase<T, Gray>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, HSI>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, HSI>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, HSL>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, HSL>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, HSV>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, HSV>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, RGB>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, RGB>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, RGBA>> for ImageBase<T, Generic4>
where T: Data,

Source§

fn from(image: ImageBase<T, RGBA>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ImageBase<T, YCrCb>> for ImageBase<T, Generic3>
where T: Data,

Source§

fn from(image: ImageBase<T, YCrCb>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, CIEXYZ>> for Image<T, RGB>

Source§

fn from(image: ImageBase<U, CIEXYZ>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic1>> for Image<T, Generic2>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic1>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic1>> for Image<T, Generic3>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic1>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic1>> for Image<T, Generic4>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic1>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic1>> for Image<T, Generic5>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic1>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic2>> for Image<T, Generic1>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic2>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic2>> for Image<T, Generic3>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic2>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic2>> for Image<T, Generic4>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic2>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic2>> for Image<T, Generic5>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic2>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic3>> for Image<T, Generic1>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic3>> for Image<T, Generic2>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic3>> for Image<T, Generic4>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic3>> for Image<T, Generic5>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic3>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic4>> for Image<T, Generic1>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic4>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic4>> for Image<T, Generic2>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic4>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic4>> for Image<T, Generic3>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic4>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic4>> for Image<T, Generic5>
where U: Data<Elem = T>, T: Copy + Num,

Source§

fn from(image: ImageBase<U, Generic4>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic5>> for Image<T, Generic1>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic5>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic5>> for Image<T, Generic2>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic5>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic5>> for Image<T, Generic3>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic5>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Generic5>> for Image<T, Generic4>
where U: Data<Elem = T>, T: Copy,

Source§

fn from(image: ImageBase<U, Generic5>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, Gray>> for Image<T, RGB>

Source§

fn from(image: ImageBase<U, Gray>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, HSV>> for Image<T, RGB>

Source§

fn from(image: ImageBase<U, HSV>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, RGB>> for Image<T, CIEXYZ>

Source§

fn from(image: ImageBase<U, RGB>) -> Self

Converts to this type from the input type.
Source§

impl<T, U> From<ImageBase<U, RGB>> for Image<T, Gray>

Source§

fn from(image: ImageBase<U, RGB>) -> Self

Converts to this type from the input type.
Source§

impl<U, T> From<ImageBase<U, RGB>> for Image<T, HSV>

Source§

fn from(image: ImageBase<U, RGB>) -> Self

Converts to this type from the input type.
Source§

impl<'a, S, C> Hash for ImageBase<S, C>
where S: Data, S::Elem: Hash, C: ColourModel,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, U, C> HistogramEqExt<T> for ImageBase<U, C>

Source§

type Output = ImageBase<OwnedRepr<T>, C>

Source§

fn equalise_hist(&self, grid: Grid<T>) -> Self::Output

Equalises an image histogram returning a new image. Grids should be for a 1xN image as the image is flattened during processing
Source§

fn equalise_hist_inplace(&mut self, grid: Grid<T>)

Equalises an image histogram inplace Grids should be for a 1xN image as the image is flattened during processing
Source§

impl<T, U, C> MedianFilterExt for ImageBase<U, C>
where U: Data<Elem = T>, T: Copy + Clone + FromPrimitive + ToPrimitive + Num + Ord, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<T>, C>

Source§

fn median_filter<E>(&self, region: E) -> Self::Output
where E: IntoDimension<Dim = Ix2>,

Run the median filter given the region. Median is assumed to be calculated independently for each channel.
Source§

impl<U, C> MorphologyExt for ImageBase<U, C>
where U: DataMut<Elem = bool>, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<bool>, C>

Source§

fn erode(&self, kernel: ArrayView2<'_, bool>) -> Self::Output

Source§

fn erode_inplace(&mut self, kernel: ArrayView2<'_, bool>)

Source§

fn dilate(&self, kernel: ArrayView2<'_, bool>) -> Self::Output

Source§

fn dilate_inplace(&mut self, kernel: ArrayView2<'_, bool>)

Source§

fn union(&self, other: &Self) -> Self::Output

Source§

fn union_inplace(&mut self, other: &Self)

Source§

fn intersection(&self, other: &Self) -> Self::Output

Source§

fn intersection_inplace(&mut self, other: &Self)

Source§

impl<T, U, C> PaddingExt<T> for ImageBase<U, C>
where U: Data<Elem = T>, T: Copy, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<T>, C>

Type of the output image
Source§

fn pad( &self, padding: (usize, usize), strategy: &dyn PaddingStrategy<T>, ) -> Self::Output

Pad the object with the given padding and strategy
Source§

impl<T, U, C> PartialEq for ImageBase<U, C>
where U: Data<Elem = T>, T: PartialEq, C: ColourModel,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, U, C> SobelExt for ImageBase<U, C>
where U: DataMut<Elem = T>, T: Copy + Clone + Num + NumAssignOps + Neg<Output = T> + FromPrimitive + Real, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<T>, C>

Type to output
Source§

fn apply_sobel(&self) -> Result<Self::Output, Error>

Returns the magnitude output of the sobel - an image of only lines
Source§

fn full_sobel(&self) -> Result<(Self::Output, Self::Output), Error>

Returns the magntitude and rotation outputs for use in other algorithms like the Canny edge detector. Rotation is in radians
Source§

impl<T, U, C> ThresholdApplyExt<T> for ImageBase<U, C>
where U: Data<Elem = T>, Image<U, C>: Clone, T: Copy + Clone + Ord + Num + NumAssignOps + ToPrimitive + FromPrimitive + PixelBound, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<bool>, C>

The output is a binary image.
Source§

fn threshold_apply(&self, lower: f64, upper: f64) -> Result<Self::Output, Error>

Apply the threshold with the given limits. Read more
Source§

impl<T, U, C> ThresholdMeanExt<T> for ImageBase<U, C>
where U: Data<Elem = T>, Image<U, C>: Clone, T: Copy + Clone + Ord + Num + NumAssignOps + ToPrimitive + FromPrimitive + PixelBound, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<bool>, C>

The Mean thresholding output is a binary image.
Source§

fn threshold_mean(&self) -> Result<Self::Output, Error>

Run the Mean threshold algorithm. Read more
Source§

impl<T, U, C> ThresholdOtsuExt<T> for ImageBase<U, C>
where U: Data<Elem = T>, Image<U, C>: Clone, T: Copy + Clone + Ord + Num + NumAssignOps + ToPrimitive + FromPrimitive + PixelBound, C: ColourModel,

Source§

type Output = ImageBase<OwnedRepr<bool>, C>

The Otsu thresholding output is a binary image.
Source§

fn threshold_otsu(&self) -> Result<Self::Output, Error>

Run the Otsu threshold algorithm. Read more
Source§

impl<T, U, C, V> TransformExt<V> for ImageBase<U, C>
where U: Data<Elem = T>, T: Copy + Clone + Num + NumAssignOps, C: ColourModel, V: Transform,

Source§

type Output = ImageBase<OwnedRepr<T>, C>

Output type for the operation
Source§

fn transform( &self, transform: &V, output_size: Option<(usize, usize)>, ) -> Result<Self::Output, TransformError>

Transforms an image given the transformation matrix and output size. Uses the source index coordinate space Assume nearest-neighbour interpolation

Auto Trait Implementations§

§

impl<T, C> Freeze for ImageBase<T, C>
where T: Freeze,

§

impl<T, C> RefUnwindSafe for ImageBase<T, C>

§

impl<T, C> Send for ImageBase<T, C>
where T: Send, C: Send,

§

impl<T, C> Sync for ImageBase<T, C>
where T: Sync, C: Sync,

§

impl<T, C> Unpin for ImageBase<T, C>
where T: Unpin, C: Unpin,

§

impl<T, C> UnwindSafe for ImageBase<T, C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V