Struct dssim_core::Dssim

source ·
pub struct Dssim { /* private fields */ }
Expand description

Configuration for the comparison

Implementations§

source§

impl Dssim

source

pub fn new() -> Dssim

Create new context for comparisons

source

pub fn set_scales(&mut self, scales: &[f64])

Set how many scales will be used, and weights of each scale

source

pub fn set_save_ssim_maps(&mut self, num_scales: u8)

Set how many scales will be kept for saving

source

pub fn create_image_rgba( &self, bitmap: &[RGBA<u8>], width: usize, height: usize ) -> Option<DssimImage<f32>>

Create image from an array of RGBA pixels (sRGB, non-premultiplied, alpha last).

If you have a slice of u8, then see rgb crate’s as_rgba().

source

pub fn create_image_rgb( &self, bitmap: &[RGB<u8>], width: usize, height: usize ) -> Option<DssimImage<f32>>

Create image from an array of packed RGB pixels (sRGB).

If you have a slice of u8, then see rgb crate’s as_rgb().

source

pub fn create_image<InBitmap, OutBitmap>( &self, src_img: &InBitmap ) -> Option<DssimImage<f32>>
where InBitmap: ToLABBitmap + Send + Sync + Downsample<Output = OutBitmap>, OutBitmap: ToLABBitmap + Send + Sync + Downsample<Output = OutBitmap>,

The input image is defined using the imgref crate, and the pixel type can be:

  • ImgVec<RGBAPLU> — RGBA premultiplied alpha, linear, float scaled to 0..1
  • ImgVec<RGBLU> — RGBA linear, float scaled to 0..1
  • ImgVec<f32> — linear light grayscale, float scaled to 0..1

And there’s ToRGBAPLU::to_rgbaplu() trait to convert the input pixels from [RGBA<u8>], [RGBA<u16>], [RGB<u8>], or RGB<u16>. See lib.rs for example how it’s done.

You can implement ToLABBitmap and Downsample traits on your own image type.

source

pub fn compare<M: Borrow<DssimImage<f32>>>( &self, original_image: &DssimImage<f32>, modified_image: M ) -> (Val, Vec<SsimMap>)

Compare original with another image. See create_image

The SsimMaps are returned only if you’ve enabled them first.

Val is a fancy wrapper for f64

Trait Implementations§

source§

impl Clone for Dssim

source§

fn clone(&self) -> Dssim

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Dssim

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Dssim

§

impl RefUnwindSafe for Dssim

§

impl Send for Dssim

§

impl Sync for Dssim

§

impl Unpin for Dssim

§

impl UnwindSafe for Dssim

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> 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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>,

§

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.