View Source NxColor (NxColor v0.0.1-dev)

NxColor implements diffenret colorspaces in Using Nx tensors.

This module helps you to load image data and convert it to different colorspaces.

Link to this section Summary

Functions

Changes the colorspace of a given NxColor.Image struct to the target_colorspace.

Creates a NxColor.Image struct from an Nx tensor.

Returns the tensor from an NxColor.Image struct.

Link to this section Functions

Link to this function

change_colorspace(image, target_colorspace, opts \\ [])

View Source
@spec change_colorspace(NxColor.Image.t(), atom(), Keyword.t()) ::
  NxColor.Image.t() | no_return()

Changes the colorspace of a given NxColor.Image struct to the target_colorspace.

parameters

Parameters

  • image: an NxColor.Image struct.
  • target_colorspace: Module of the colorspace you want to convert your image colorspace into.
  • opts: Colorspace specific options. See target colorspace module documentation for more info.
Link to this function

from_nx(tensor, opts \\ [])

View Source
@spec from_nx(Nx.Tensor.t(), Keyword.t()) :: NxColor.Image.t()

Creates a NxColor.Image struct from an Nx tensor.

parameters

Parameters

  • tensor: The input image or images.
  • opts: Options keyword list.
    • channel: Determines in which dimention the color channel is in the given tensor. Can be either :last or :first. Defaults to :last Note that :first means first dimension in each image.
    • colorspace: In which colorspace is the current image. Defaults to: NxColor.Colorspace.RGB

examples

Examples

iex> NxColor.from_nx(Nx.tensor([[[255, 255, 255]]]))
#NxColor.Image<Elixir.NxColor.Colorspace.RGB>
Link to this function

to_nx(image, opts \\ [])

View Source
@spec to_nx(NxColor.Image.t(), Keyword.t()) :: Nx.Tensor.t()

Returns the tensor from an NxColor.Image struct.

parameters

Parameters

  • image: an NxColor.Image struct.
  • opts: Options keyword list.
    • channel: Determines in which dimension the color channel should be in the output tensor. Can be either :first or :last. Defaults to :last Note that :first means first dimension in each image.