Commit 74ae8cb3 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Cleanup Sauvola's binarization code.

	* binarization/sauvola_threshold.hh,
	* binarization/sauvola.hh: Use fun::v2v::rgb_to_int_u8.

	* binarization/sauvola_ms.hh: New. Sauvola multi-scale routine.

	* src/binarization/sauvola.cc: Make the window size a program
	argument.

	* src/binarization/sauvola_ms.cc: Use Sauvola multi-scale routine.
parent 7d4f627f
2009-12-14 Guillaume Lazzara <z@lrde.epita.fr>
Cleanup Sauvola's binarization code.
* binarization/sauvola_threshold.hh,
* binarization/sauvola.hh: Use fun::v2v::rgb_to_int_u8.
* binarization/sauvola_ms.hh: New. Sauvola multi-scale routine.
* src/binarization/sauvola.cc: Make the window size a program
argument.
* src/binarization/sauvola_ms.cc: Use Sauvola multi-scale routine.
2009-12-14 Guillaume Lazzara <z@lrde.epita.fr>
* core/object_image.hh: Make use of mln::labeled_image_base.
......
......@@ -35,6 +35,8 @@
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
# include <mln/fun/v2v/rgb_to_int_u.hh>
# include <scribo/binarization/sauvola_threshold.hh>
# include <scribo/binarization/binarize.hh>
......@@ -106,7 +108,7 @@ namespace scribo
mln_precondition(exact(input).is_valid());
mln_ch_value(I, value::int_u8) gima;
gima = data::transform(input, internal::rgb8_to_int_u8());
gima = data::transform(input, mln::fun::v2v::rgb_to_int_u<8>());
mln_ch_value(I, bool)
output = binarize(gima,
......
This diff is collapsed.
......@@ -44,6 +44,8 @@
# include <mln/pw/all.hh>
# include <mln/core/routine/duplicate.hh>
# include <mln/fun/v2v/rgb_to_int_u.hh>
# include <scribo/core/init_integral_image.hh>
......@@ -96,16 +98,6 @@ namespace scribo
namespace internal
{
struct rgb8_to_int_u8 : Function_v2v< rgb8_to_int_u8 >
{
typedef value::int_u8 result;
result operator()(const value::rgb8& c) const
{
return (c.red() + c.green() + c.blue()) / 3;
}
};
/*! \brief compute Sauvola's threshold applying directly the formula.
\param[in] m_x_y Mean value.
......@@ -383,7 +375,7 @@ namespace scribo
mln_ch_value(I, value::int_u8) gima;
gima = data::transform(input,
internal::rgb8_to_int_u8());
mln::fun::v2v::rgb_to_int_u<8>());
mln_ch_value(I, value::int_u8)
output = impl::generic::sauvola_threshold(gima, window_size,
......
......@@ -33,6 +33,7 @@
const char *args_desc[][2] =
{
{ "input.ppm", "A color image." },
{ "wsize", "Window size (Common value: 51)." },
{0, 0}
};
......@@ -42,10 +43,10 @@ int main(int argc, char *argv[])
using namespace mln;
using value::rgb8;
if (argc != 3)
if (argc != 4)
return scribo::debug::usage(argv,
"Binarization of a color image based on Sauvola's algorithm.",
"input.ppm output.pbm",
"input.ppm wsize output.pbm",
args_desc, "A binary image.");
trace::entering("main");
......@@ -53,7 +54,7 @@ int main(int argc, char *argv[])
image2d<rgb8> input;
io::ppm::load(input, argv[1]);
io::pbm::save(scribo::binarization::sauvola(input), argv[2]);
io::pbm::save(scribo::binarization::sauvola(input, atoi(argv[2])), argv[3]);
trace::exiting("main");
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment