Module Picture

module Picture: sig .. end
Processing pictures


Basic Picture and Image-related Matrix Functions


type picture = {
   r :Matrix.matrix_int;
   g :Matrix.matrix_int;
   b :Matrix.matrix_int;
}
val dimx : picture -> int
val dimy : picture -> int
val read_pic : string -> picture
Read a picture from a scanning buffer.
val fprint_ppm : Format.formatter -> picture -> unit
Print a picture in the simple PPM format to a formatter.
val sprint_ppm : picture -> string
Print a picture in the simple PPM format to a string.
val flip : picture -> picture
Flip a picture.
val brightness : picture -> Matrix.F.t
Floating-point matrix of brightness in range 0..1.

Convert to Graphics-friendly format.

val image : picture -> int array array
Fill the RGB channels from floats in range 0..1.
val monochrome : Matrix.F.t -> picture
val black_n_white : Matrix.B.t -> picture
Color-encode numbers, 0 remains black, possible clashes.
val colorful : Matrix.I.t -> picture
val convolution : filter:Matrix.F.t -> image:Matrix.F.t -> Matrix.F.t
Discrete 2D convolution: around each point of image, sum all elements of the product of filter and corresponding image elements.
val normalize : Matrix.F.t -> Matrix.F.t
Normalize

Specific Image-related Matrix Trasformations


val sobel_x : Matrix.F.t
Sobel differential operator.
val sobel_y : Matrix.F.t
Scharr differential operator.
val scharr_x : Matrix.F.t
val scharr_y : Matrix.F.t
Gaussian smoothing operator.
val gaussian : Matrix.F.t
val canny : hi_thr:float -> lo_thr:float -> picture -> Matrix.B.t
Detect edges: hi_thr how insensitive to new edges, lo_thr how insensitive to edge continuations, extend how many pixels to prolong existing edge.
val super_canny : extend:int -> hi_thr:float -> lo_thr:float -> picture -> Matrix.B.t
val regions : Matrix.B.t -> Matrix.I.t
Compute edge-separated regions, region numbers start from 1, remaining edges are pseudo-region 0.
val regcolors : picture -> Matrix.I.t -> int array * int array * int array
Average colors per region.
val colorcode : Matrix.I.t -> int array * int array * int array -> picture