List Info

Thread: "ocaml_beginners"::[] Re: camlimages for image binarization




"ocaml_beginners"::[] Re: camlimages for image binarization
country flaguser name
United States
2008-03-05 08:45:18

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_beginnersyahoogroups.com, Florent Monnier <fmonnier...>
wrote:
&gt;
> noureddine_ms a écrit :
> > hi all
> > has any one used camlimages for binarizing images?
> > if so, can u provide us with guidelines please
&gt; >
>; > thx
>
> not done with camlimages but with ocaml-imagemagick:
>
> ------ (usage) ------
&gt; ocaml binarize-image.ml <image&gt; <threshold level> [blur]
&gt; 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) ------
&gt; #! /usr/bin/env ocaml
&gt; #directory "+;libMagick&quot;
>; #load "magick.cma";
> open Magick
&gt; open Imper
&gt;
> 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)
&gt; ;;
>
> 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.
>
>
> --
>

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: camlimages for image binarization
country flaguser name
United States
2008-03-06 07:04:34

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_beginnersyahoogroups.com, "noureddine_ms&quot;
<;noureddine_ms...> wrote:
&gt;
> I've installed ImageMagick but I don't know how to make ocaml see it.
> every time I try to compile, it says:
&gt; File "binarize-image.ml", line 4, characters 0-11:
&gt; Unbound module Magick
&gt;
> Any one can help plz
> Sorry I'm a newbie
>
> thanks
&gt;
> --- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Florent Monnier <fmonnier>
>; wrote:
&gt; >
>; > noureddine_ms a écrit :
> > > hi all
> > > has any one used camlimages for binarizing images?
> > > if so, can u provide us with guidelines please
&gt; > >
>; > > thx
> >
> > not done with camlimages but with ocaml-imagemagick:
> >
> > ------ (usage) ------
&gt; > ocaml binarize-image.ml <image&gt; <threshold level> [blur]
&gt; > 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) ------
&gt; > #! /usr/bin/env ocaml
&gt; > #directory "+;libMagick&quot;
>; > #load "magick.cma";
> > open Magick
&gt; > open Imper
&gt; >
> > 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)
&gt; > ;;
> >
> > 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.
> >
> >
> > --
> >
>;

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )