Skip to main content

ColorConversion

Trait ColorConversion 

pub trait ColorConversion {
    // Required methods
    fn rgb2gray(self) -> Tensor<4>;
    fn gray2rgb(self) -> Tensor<4>;
    fn rgb2hsv(self) -> Tensor<4>;
    fn hsv2rgb(self) -> Tensor<4>;
}
Expand description

Color space conversion tensor operations.

Required Methods§

fn rgb2gray(self) -> Tensor<4>

Converts a batch of images from the RGB color space to grayscale.

§Arguments
  • self: A batched image tensor of shape [batch, channel, height, width] in the 0.0..=1.0 range.
§Returns

The grayscale image tensor of shape [batch, 1, height, width].

fn gray2rgb(self) -> Tensor<4>

Converts a batch of grayscale images to the RGB color space.

§Arguments
  • self: A batched image tensor of shape [batch, 1, height, width].
§Returns

The converted batched image tensor of shape [batch, 3, height, width]

fn rgb2hsv(self) -> Tensor<4>

Converts a batch of images from the RGB color space to the HSV color space.

§Arguments
  • self: A batched image tensor of shape [batch, channel, height, width] in the 0.0..=1.0 range.
§Returns

The same-shape image tensor in HSV color space.

fn hsv2rgb(self) -> Tensor<4>

Converts a batch of images from the HSV color space to the RGB color space.

§Arguments
  • self: A batched image tensor of shape [batch, channel, height, width]. The first channel (hue) is in the 0.0..360.0 range. The other two (saturation and value) are in the 0.0..=1.0 range.
§Returns

The same-shape image tensor in RGB color space.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl ColorConversion for Tensor<4>

Formulas derived from the OpenCV docs.