ImageFormat

Supported image output formats.

Union cases

NameDescription
Jpeg
Png
Webp

Instance members

NameDescription
this.IsJpeg
this.IsPng
this.IsWebp

Image

Image I/O and SKBitmap-Tensor conversion.

FunctionDescription
fromTensor tensorConvert a [3, H, W] float32 tensor in [0, 1] to an SKBitmap.
load path deviceLoad an image file as a [3, H, W] float32 tensor in [0, 1].
loadStream stream deviceLoad an image from a stream as a [3, H, W] float32 tensor in [0, 1].
save tensor path format _qualitySave a [3, H, W] float32 tensor as an image file.
saveGrid tensor path format quality nrowSave a batch tensor [N, C, H, W] as a grid image with nrow images per row.
toTensor bitmap deviceConvert an SKBitmap to a [3, H, W] float32 tensor in [0, 1].
Alpha channel is discarded; output has 3 channels (RGB).

fromTensor

fromTensor tensor

Convert a [3, H, W] float32 tensor in [0, 1] to an SKBitmap.

Parameters

  • tensor : Tensor

Returns SKBitmap


load

load path device

Load an image file as a [3, H, W] float32 tensor in [0, 1].

Parameters

  • path : string
  • device : Device

Returns Tensor


loadStream

loadStream stream device

Load an image from a stream as a [3, H, W] float32 tensor in [0, 1].

Parameters

  • stream : Stream
  • device : Device

Returns Tensor


save

save tensor path format _quality

Save a [3, H, W] float32 tensor as an image file.

Parameters

  • tensor : Tensor
  • path : string
  • format : ImageFormat
  • _quality : int

saveGrid

saveGrid tensor path format quality nrow

Save a batch tensor [N, C, H, W] as a grid image with nrow images per row.

Parameters

  • tensor : Tensor
  • path : string
  • format : ImageFormat
  • quality : int
  • nrow : int

toTensor

toTensor bitmap device

Convert an SKBitmap to a [3, H, W] float32 tensor in [0, 1]. Alpha channel is discarded; output has 3 channels (RGB).

Parameters

  • bitmap : SKBitmap
  • device : Device

Returns Tensor