WOW
I've installed ImageMagick and then then Interface developed by
Florent Monnier and it worked well.
I faced a problem when I compiled the interface from source but now it
works just fine.
Thanks Florent
appreciated
--- In ocaml_beginners%40yahoogroups.com">ocaml_beginners
yahoogroups.com, "noureddine_ms"
<noureddine_ms
...> wrote:
>
> I've installed ImageMagick but I don't know how to make ocaml see it.
> every time I try to compile, it says:
> File "binarize-image.ml", line 4, characters 0-11:
> Unbound module Magick
>
> Any one can help plz
> Sorry I'm a newbie 
>
> thanks
>
> --- In ocaml_beginners%40yahoogroups.com">ocaml_beginners
yahoogroups.com, Florent Monnier <fmonnier
>
> wrote:
> >
> > noureddine_ms a écrit :
> > > hi all
> > > has any one used camlimages for binarizing images?
> > > if so, can u provide us with guidelines please
> > >
> > > thx
> >
> > not done with camlimages but with ocaml-imagemagick:
> >
> > ------ (usage) ------
> > ocaml binarize-image.ml <image> <threshold level> [blur]
> > threshold level: a percentage (between 0.0 and 1.0)
> > blur: optional argument
> > example:
> > ocaml binarize-image.ml ~/gnuart/1-006.png 0.3 0.7
> > ----------
> >
> > ------ (binarize-image.ml) ------
> > #! /usr/bin/env ocaml
> > #directory "+;libMagick"
> > #load "magick.cma"
> > open Magick
> > open Imper
> >
> > let binarize_image ~filename ~percent ?(do_blur=0.0) () =
> > let img = read_image ~filename in
> > let p = 65535. *. percent in
> > let level = (truncate(p +. 0.5)) in
> > (* you can modify this part to get thresholding differently
> > along each channel *)
> > let red_lvl, green_lvl, blue_lvl = level, level, level in
> > let threshold = Printf.sprintf "%d,%d,%d" red_lvl green_lvl
> blue_lvl in
> > (* applying a small blur, removes noisy details *)
> > if do_blur <> 0.0 then
> > blur img ~sigma:do_blur ();
> > black_threshold img ~threshold;
> > white_threshold img ~threshold;
> > (img)
> > ;;
> >
> > let () =
> > let argc = Array.length Sys.argv in
> > let filename = Sys.argv.(1)
> > and percent = float_of_string Sys.argv.(2)
> > and do_blur = if argc = 4 then float_of_string Sys.argv.(3) else 0.0
> > in
> > let img = binarize_image ~filename ~percent ~do_blur () in
> >
> > display img; (* show the result *)
> >
> > (* add the prefix "bin_" to the saved image *)
> > let bin_file =
> > let dir = (Filename.dirname filename)
> > and file = "bin_" ^ (Filename.basename filename)
> > in
> > Filename.concat dir file
> > in
> > write_image img ~filename:bin_file;
> > ;;
> > ----------
> >
> >
> > Depending of what your trying to do there could be other imagemagick
> filters
> > you may prefer to use. For exemple instead of blur there are filters
> that
> > only blur pixels in the same color area. There are also different
> threshold
> > filters.
> >
> >
> > --
> >
>
.