package torch

  1. Overview
  2. Docs

Image writing

buffer simply is an alias to a bigarray with c_layout. Two kind of pixel buffers are manipulated:

  • int8 for images with 8-bit channels
  • float32 for images with floating point channels

Content of an image with c channels of width w and height h is represented as a contiguous sequence of items such that:

  • channels are interleaved
  • each pixel is made of c items
  • each line is made of w pixels
  • image is made of h lines
type 'kind buffer = ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t constraint 'kind = ('a, 'b) Stdlib.Bigarray.kind
type float32 = (float, Stdlib.Bigarray.float32_elt) Stdlib.Bigarray.kind
type int8 = (int, Stdlib.Bigarray.int8_unsigned_elt) Stdlib.Bigarray.kind
val png : string -> w:int -> h:int -> c:int -> int8 buffer -> unit
val bmp : string -> w:int -> h:int -> c:int -> int8 buffer -> unit
val tga : string -> w:int -> h:int -> c:int -> int8 buffer -> unit
val hdr : string -> w:int -> h:int -> c:int -> float32 buffer -> unit
val jpg : string -> w:int -> h:int -> c:int -> quality:int -> int8 buffer -> unit
OCaml

Innovation. Community. Security.