1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #directory "/usr/lib/ocaml/lablgtk2";;
#load "lablgtk.cma";;
#directory "/usr/lib/ocaml/camlimages";;
#load "graphics.cma";;
#load "camlimages_core.cma";;
#load "camlimages_png.cma";;
open Images;;
open OImages;;
open Info;;
open Graphics;;
open Graphic_image;;
let transform img =
let w, h = (img#width, img#height) in
let img_mat = (Array.make_matrix w h 0) in
for i = 0 to (w - 1) do
for j = 0 to (h - 1) do
let pixel = img#get i j in
img_mat.(i).(j) <- (Graphics.rgb pixel.r pixel.g pixel.b)
done;
done;
img_mat
;;
let image = (OImages.rgb24 (OImages.load "Basketball.png" []));;
let img = (transform image);; |
Partager