Trait rustml::opencv::Image [] [src]

pub trait Image {
    fn new(width: usize, height: usize) -> Self;
    fn buffer(&self) -> *const IplImage;
    fn pixel_as_rgb(&self, x: usize, y: usize) -> Option<Rgb>;
    fn set_pixel_from_rgb(&self, x: usize, y: usize, p: &Rgb);
    fn grid(images: &Vec<Self>, cols: usize, space: usize) -> Option<Self>;

    fn width(&self) -> usize { ... }
    fn height(&self) -> usize { ... }
    fn depth(&self) -> usize { ... }
    fn widthstep(&self) -> usize { ... }
    fn channels(&self) -> usize { ... }
    fn to_file(&self, fname: &str) -> bool { ... }
    fn copy_from<T: Image>(&mut self, img: &T, x: usize, y: usize, width: usize, height: usize, dstx: usize, dsty: usize) { ... }
    fn draw_text(&mut self, txt: &str, x: usize, y: usize, font: &Font) { ... }
}

Trait for images.

Required Methods

fn new(width: usize, height: usize) -> Self

Creates a new image with the given width and height.

fn buffer(&self) -> *const IplImage

Returns the internal representation of the image.

fn pixel_as_rgb(&self, x: usize, y: usize) -> Option<Rgb>

Returns the RGB value of the pixel at location (x, y).

If the image is a grayscale image all color components have the same value.

fn set_pixel_from_rgb(&self, x: usize, y: usize, p: &Rgb)

Sets the pixel at the location (x, y) to the value specified by p.

If the image is a frayscale image the following grayscale value is set: val = 0.299 * red + 0.587 * green + 0.114 * blue

fn grid(images: &Vec<Self>, cols: usize, space: usize) -> Option<Self>

Creates a new image by organizing the given list of images into a grid.

All images must have the same size, otherwise returns None. The number of columns of the grid is specified with the parameter cols. The parameter space specifies the number of pixels between each image that is used to separate them.

Provided Methods

fn width(&self) -> usize

Returns the width of the image.

fn height(&self) -> usize

Returns the height of the image.

fn depth(&self) -> usize

Returns the color depth of the image.

fn widthstep(&self) -> usize

Internal method which returns the length of one row in bytes.

Due to the fact that rows might by aligned the number of bytes might be greater than the width of the image.

fn channels(&self) -> usize

Returns the number of color components used for this image.

fn to_file(&self, fname: &str) -> bool

Writes the image into a file.

The file format that is written depends on the extension of the filename. Supported formats are JPEG, PNG, PPM, PGM, PBM. Returns false if file could not be written and true on success.

fn copy_from<T: Image>(&mut self, img: &T, x: usize, y: usize, width: usize, height: usize, dstx: usize, dsty: usize)

Copies an area from the given image at location (x,y ) with width width and height height into this image at position (dstx, dsty).

fn draw_text(&mut self, txt: &str, x: usize, y: usize, font: &Font)

Draws text on the image at position (x, y).

Implementors