[][src]Trait show_image::tch::TensorAsImage

pub trait TensorAsImage {
    fn as_image<'a>(
        &'a self,
        pixel_format: TensorPixelFormat
    ) -> Result<TensorImage<'a>, String>; fn as_interlaced<'a>(
        &'a self,
        pixel_format: PixelFormat
    ) -> Result<TensorImage<'a>, String> { ... }
fn as_planar<'a>(
        &'a self,
        pixel_format: PixelFormat
    ) -> Result<TensorImage<'a>, String> { ... }
fn as_image_guess<'a>(
        &'a self,
        color_format: ColorFormat
    ) -> Result<TensorImage<'a>, String> { ... }
fn as_image_guess_rgb<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_image_guess_bgr<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_mono8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_interlaced_rgb8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_interlaced_rgba8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_interlaced_bgr8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_interlaced_bgra8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_planar_rgb8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_planar_rgba8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_planar_bgr8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... }
fn as_planar_bgra8<'a>(&'a self) -> Result<TensorImage<'a>, String> { ... } }

Extension trait to allow displaying tensors as image.

The tensor data will always be copied. Additionaly, the data will be converted to 8 bit integers, and planar data will be converted to interlaced data.

The original tensor is unaffected, but the conversion can be expensive. If you also need to convert the tensor, consider doing so before displaying it.

Required methods

fn as_image<'a>(
    &'a self,
    pixel_format: TensorPixelFormat
) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage that implements ImageData.

This function requires you to specify the pixel format of the tensor, or a preferred color format to have the library guess based on the tensor shape.

See the other functions in the trait for easier shorthands.

Loading content...

Provided methods

fn as_interlaced<'a>(
    &'a self,
    pixel_format: PixelFormat
) -> Result<TensorImage<'a>, String>

Wrap the tensor with a known pixel format in a TensorImage, assuming it holds interlaced pixel data.

fn as_planar<'a>(
    &'a self,
    pixel_format: PixelFormat
) -> Result<TensorImage<'a>, String>

Wrap the tensor with a known pixel format in a TensorImage, assuming it holds planaer pixel data.

fn as_image_guess<'a>(
    &'a self,
    color_format: ColorFormat
) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage.

The pixel format of the tensor will be guessed based on the shape. The color_format argument determines if tensors with 3 or 4 channels are interpreted as RGB or BGR.

fn as_image_guess_rgb<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage.

The pixel format of the tensor will be guessed based on the shape. Tensors with 3 or 4 channels will be interpreted as RGB.

fn as_image_guess_bgr<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage.

The pixel format of the tensor will be guessed based on the shape. Tensors with 3 or 4 channels will be interpreted as BGR.

fn as_mono8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds monochrome data.

fn as_interlaced_rgb8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds interlaced RGB data.

fn as_interlaced_rgba8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds interlaced RGBA data.

fn as_interlaced_bgr8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds interlaced BGR data.

fn as_interlaced_bgra8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds interlaced BGRA data.

fn as_planar_rgb8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds planar RGB data.

fn as_planar_rgba8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds planar RGBA data.

fn as_planar_bgr8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds planar BGR data.

fn as_planar_bgra8<'a>(&'a self) -> Result<TensorImage<'a>, String>

Wrap the tensor in a TensorImage, assuming it holds planar BGRA data.

Loading content...

Implementations on Foreign Types

impl TensorAsImage for Tensor[src]

Loading content...

Implementors

Loading content...