To focus the search input from anywhere on the page, press the 'S' key.
in-package search v0.1.0
bimage — Image processing library
bimage is an image processing library for OCaml.
Simple image type based on bigarrays
Supports u8, u16, i32, i64, f32, f64, complex32 and complex64 datatypes
Multiple layout support (Planar/Interleaved)
Composable image operations
Image I/O using ImageMagick/GraphicsMagick and FFmpeg in (
Support for displaying images using GTK (
bimage-gtk) or SDL (
bimage is distributed under the ISC license.
bimage can be installed with
opam install bimage
bimage-unix, which provides
FFmpeg bindings, can be installed by running:
opam install bimage-unix
If you don't use
opam consult the
opam file for build
An example showing how to create an image and how to use
open Bimage let _ = (* Create a new image *) let a = Image.create u8 gray 64 64 in (* Iterate over each pixel *) let _ = Image.for_each (fun x y _px -> Image.set a x y 0 (x + y) ) a in (* Save the image using ImageMagick *) Bimage_unix.Magick.write "test1.jpg" a
An example using
Op.t to run a filter on an image:
open Bimage open Bimage_unix let _ = (* Load an image using ImageMagick *) let a = match Magick.read f32 rgb "test/test.jpg" with | Ok img -> img | Error e -> failwith (Error.to_string e) in (* Create an operation to convert to grayscale and subtract 1.0 *) let f = Op.(grayscale &- scalar 0.5) in (* Create a destination image *) let dest = Image.like_with_color gray a in (* Run the operation *) let () = Op.eval f ~output:dest [| a |] in (* Save the image using ImageMagick *) Magick.write "test2.jpg" dest
The documentation and API reference is generated from the source
interfaces. It can be consulted online or via
odig doc bimage.
In the distribution sample programs and tests are located in the
test directory. They can be built and run