package bimage

  1. Overview
  2. Docs

Module Bimage.ImageSource

The Image module defines a simple interface for manipulating image data

Sourcetype layout =
  1. | Planar
  2. | Interleaved
    (*

    Image pixel layout. Planar is RRRGGGBBB and Interleaved is RGBRGBRGB

    *)
Sourcetype ('a, 'b, 'c) t = {
  1. width : int;
  2. height : int;
  3. color : 'c Color.t;
  4. layout : layout;
  5. data : ('a, 'b) Data.t;
}

Image type

Sourceval create : ?layout:layout -> ('a, 'b) kind -> 'c Color.t -> int -> int -> ('a, 'b, 'c) t

create kind color width height makes a new image with the given kind, color and dimensions

Sourceval compare : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> int
Sourceval equal : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> bool
Sourceval data : ('a, 'b, 'c) t -> ('a, 'b) Data.t

Get image data

Sourceval of_data : 'c Color.t -> int -> int -> layout -> ('a, 'b) Data.t -> ('a, 'b, 'c) t

of_data color width height layout data makes a new image from existing image data with the given kind, color, layout, and dimensions

Sourceval like : ('a, 'b, 'c) t -> ('a, 'b, 'c) t

like img creates a new image with the same dimensions, color and kind as img

Sourceval like_with_color : 'd Color.t -> ('a, 'b, 'c) t -> ('a, 'b, 'd) t
Sourceval like_with_kind : ('d, 'e) kind -> ('a, 'b, 'c) t -> ('d, 'e, 'c) t
Sourceval like_with_layout : layout -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t
Sourceval copy : ('a, 'b, 'c) t -> ('a, 'b, 'c) t

Makes a copy of an image and underlying image data

Sourceval copy_to : dest:('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit

Copy pixels from one image to another

Sourceval channels : ('a, 'b, 'c) t -> int

Returns the number of channels in an image

Sourceval layout : ('a, 'b, 'c) t -> layout

Returns the image layout type

Sourceval length : ('a, 'b, 'c) t -> int

Returns the number of values contained in an image

Sourceval kind : ('a, 'b, 'c) t -> ('a, 'b) kind

Returns the image kind

Sourceval color : ('a, 'b, 'c) t -> 'c Color.t

Returns the image color type

Sourceval shape : ('a, 'b, 'c) t -> int * int * int

Returns the width, height and channels

Sourceval convert_to : dest:('d, 'e, 'c) t -> ('a, 'b, 'c) t -> unit

Convert an image to an existing image of another kind

Sourceval convert : ('d, 'e) kind -> ('a, 'b, 'c) t -> ('d, 'e, 'c) t

Convert an image to a new image of another kind

Sourceval of_any_color : ('a, 'b, any) t -> 'c Color.t -> (('a, 'b, 'c) t, Error.t) result

Convert from any color to the given color

Sourceval get : ('a, 'b, 'c) t -> int -> int -> int -> 'a

get image x y c returns a the value at (x, y, c)

Sourceval set : ('a, 'b, 'c) t -> int -> int -> int -> 'a -> unit

Set a single channel of the given image at (x, y)

Sourceval get_f : ('a, 'b, 'c) t -> int -> int -> int -> float

get_f image x y c returns the float value at (x, y, c)

Sourceval set_f : ('a, 'b, 'c) t -> int -> int -> int -> float -> unit

Set a single channel of the given image at (x, y) using a float value

Sourceval get_norm : ('a, 'b, 'c) t -> int -> int -> int -> float

get_f image x y c returns the normalized float value at (x, y, c)

Sourceval set_norm : ('a, 'b, 'c) t -> int -> int -> int -> float -> unit

Set a single channel of the given image at (x, y) using a normalized float value

Sourceval get_pixel_norm : ('a, 'b, 'c) t -> ?dest:Pixel.t -> int -> int -> Pixel.t

get_pixel image x y returns a normalized pixel representation of image data at (x, y)

Sourceval set_pixel_norm : ('a, 'b, 'c) t -> int -> int -> Pixel.t -> unit

set_pixel image x y px sets the normalized value of image at (x, y) to px

Sourceval get_pixel : ('a, 'b, 'c) t -> ?dest:Pixel.t -> int -> int -> Pixel.t

get_pixel image x y returns a pixel representation of image data at (x, y)

Sourceval set_pixel : ('a, 'b, 'c) t -> int -> int -> Pixel.t -> unit

set_pixel image x y px sets the value of image at (x, y) to px

Sourceval get_data : ('a, 'b, 'c) t -> ?dest:('a, 'b) Data.t -> int -> int -> ('a, 'b) Data.t

get_data image x y returns image data at (x, y)

Sourceval set_data : ('a, 'b, 'c) t -> int -> int -> ('a, 'b) Data.t -> unit

set_data image x y px sets the value of image at (x, y) to px

Sourceval for_each : (int -> int -> ('a, 'b) Data.t -> unit) -> ?x:int -> ?y:int -> ?width:int -> ?height:int -> ('a, 'b, 'c) t -> unit

Iterate over each pixel in an image, or a rectangle segment of an image specified by x, y, width, and height. The data segment used in the callback is mutable and will write directly to the underlying image data.

Sourceval for_each_pixel : (int -> int -> Pixel.t -> unit) -> ?x:int -> ?y:int -> ?width:int -> ?height:int -> ('a, 'b, 'c) t -> unit
Sourceval avg : ?x:int -> ?y:int -> ?width:int -> ?height:int -> ('a, 'b, 'c) t -> (float, f32) Data.t

Get the average pixel of an image or region of an image

Sourceval convert_layout : layout -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t

Convert an image to the given layout

Sourceval crop : ('a, 'b, 'c) t -> x:int -> y:int -> width:int -> height:int -> ('a, 'b, 'c) t

Extract the sub-image specified by the given dimensions

Sourceval rotate_90 : ('a, 'b, 'c) t -> ('a, 'b, 'c) t

Rotate an image 90 degrees

Sourceval rotate_180 : ('a, 'b, 'c) t -> ('a, 'b, 'c) t

Rotate an image 180 degrees

Sourceval rotate_270 : ('a, 'b, 'c) t -> ('a, 'b, 'c) t

Rotate an image 270 degrees

Sourceval resize : int -> int -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t

Scale an image to the given size

Sourceval mean_std : ?channel:int -> ('a, 'b, 'c) t -> float * float

Calculate the mean and standard deviation of an image

Sourceval fold : ('a -> 'd -> 'd) -> ('a, 'b, 'c) t -> 'd -> 'd
Sourceval fold2 : ('a -> 'e -> 'd -> 'd) -> ('a, 'b, 'c) t -> ('e, 'f, 'c) t -> 'd -> 'd
Sourceval fold_data : (int -> int -> ('a, 'b) Data.t -> 'd -> 'd) -> ('a, 'b, 'c) t -> 'd -> 'd
Sourceval fold_data2 : (int -> int -> ('a, 'b) Data.t -> ('e, 'f) Data.t -> 'd -> 'd) -> ('a, 'b, 'c) t -> ('e, 'f, 'c) t -> 'd -> 'd
Sourceval map_inplace : ('a -> 'a) -> ('a, 'b, 'c) t -> unit
Sourceval map : ('a -> 'a) -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t
Sourceval map2_inplace : ('a -> 'd -> 'a) -> ('a, 'b, 'c) t -> ('d, 'e, 'f) t -> unit
Sourceval map2 : ('a -> 'd -> 'a) -> ('a, 'b, 'c) t -> ('d, 'e, 'f) t -> ('a, 'b, 'c) t
Sourcemodule Diff : sig ... end
Sourceval diff : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> Diff.diff
OCaml

Innovation. Community. Security.