Trait picto::processing::sample::Sample [] [src]

pub trait Sample<PI, CI, PO, CO> where
    PI: Read<CI>,
    CI: Channel,
    PO: Write<CO>,
    CO: Channel
{ fn sample<'o, A, O>(self, output: O, mode: Orientation)
    where
        A: Sampler,
        O: Into<Write<'o, PO, CO>>
; fn sample_with<'o, F, O>(
        self,
        output: O,
        mode: Orientation,
        support: f32,
        kernel: F
    )
    where
        F: FnMut(f32) -> f32,
        O: Into<Write<'o, PO, CO>>
; }

Trait for samplable types.

Required Methods

Sample in the given direction.

Example

use picto::read;
use picto::buffer;
use picto::color::Rgb;
use picto::processing::prelude::*;

let     image    = read::from_path::<Rgb, u8, _>("tests/boat.xyz").unwrap();
let mut vertical = buffer::Rgb::new(image.width(), image.height() * 2);
let mut resized  = buffer::Rgb::new(image.width() * 2, image.height() * 2);

image.sample::<sampler::Gaussian, _>(&mut vertical, sample::Vertically);
vertical.sample::<sampler::Gaussian, _>(&mut resized, sample::Horizontally);

Sample in the given direction with the given support and kernel function.

Example

use picto::read;
use picto::buffer;
use picto::color::Rgb;
use picto::processing::prelude::*;

let     image    = read::from_path::<Rgb, u8, _>("tests/boat.xyz").unwrap();
let mut vertical = buffer::Rgb::new(image.width(), image.height() * 2);
let mut resized  = buffer::Rgb::new(image.width() * 2, image.height() * 2);

// Nearest neighbor sampling.
image.sample_with(&mut vertical, sample::Vertically, 0.5, |x| if x.abs() <= 0.5 { 1.0 } else { 0.0 });
vertical.sample_with(&mut resized, sample::Horizontally, 0.5, |x| if x.abs() <= 0.5 { 1.0 } else { 0.0 });

Implementors