* z/sauvola_ms_rv/pbm_color_diff.cc,
* z/sauvola_ms_rv/pgm_color_diff.cc: New.
---
scribo/sandbox/ChangeLog | 7 +++++++
.../{pgm_color_diff.cc => pbm_color_diff.cc} | 17 ++++++++++-------
scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc | 2 +-
3 files changed, 18 insertions(+), 8 deletions(-)
copy scribo/sandbox/z/sauvola_ms_rv/{pgm_color_diff.cc => pbm_color_diff.cc} (72%)
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog
index 2c0068f..71ad3f4 100644
--- a/scribo/sandbox/ChangeLog
+++ b/scribo/sandbox/ChangeLog
@@ -1,5 +1,12 @@
2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ New tools.
+
+ * z/sauvola_ms_rv/pbm_color_diff.cc,
+ * z/sauvola_ms_rv/pgm_color_diff.cc: New.
+
+2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* z/sauvola_ms_rv/dump_color_sign.cc: New.
2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
b/scribo/sandbox/z/sauvola_ms_rv/pbm_color_diff.cc
similarity index 72%
copy from scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
copy to scribo/sandbox/z/sauvola_ms_rv/pbm_color_diff.cc
index 7474c46..b49f40b 100644
--- a/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
+++ b/scribo/sandbox/z/sauvola_ms_rv/pbm_color_diff.cc
@@ -2,10 +2,11 @@
#include <mln/core/image/image2d.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/int_u8.hh>
-#include <mln/io/pgm/load.hh>
+#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <mln/data/transform.hh>
#include <mln/arith/minus.hh>
+#include <mln/data/convert.hh>
namespace mln
{
@@ -21,7 +22,7 @@ namespace mln
int v_d2 = std::abs(v / 2);
if (v >= -threshold_ && v <= threshold_)
- return value::rgb8(255, 255, 255);
+ return value::rgb8(0, 0, 0);
else if (v > threshold_)
return value::rgb8(v_d2, 128 + v_d2, v_d2);
else
@@ -42,16 +43,18 @@ int main(int argc, char *argv[])
if (argc != 5)
{
- std::cout << "Usage: " << argv[0] << " in.pgm
ref.pgm threshold out.ppm" << std::endl;
+ std::cout << "Usage: " << argv[0] << " in.pbm
ref.pbm threshold out.ppm" << std::endl;
return 1;
}
- image2d<value::int_u8> input, ref;
+ image2d<bool> input, ref;
- io::pgm::load(input, argv[1]);
- io::pgm::load(ref, argv[2]);
+ io::pbm::load(input, argv[1]);
+ io::pbm::load(ref, argv[2]);
- image2d<int> diff = input - ref;
+ image2d<int>
+ diff = data::convert(value::int_u8(), input)
+ - data::convert(value::int_u8(), ref);
color_diff f(atoi(argv[3]));
image2d<value::rgb8> result = data::transform(diff, f);
diff --git a/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
b/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
index 7474c46..d9c677a 100644
--- a/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
+++ b/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
@@ -21,7 +21,7 @@ namespace mln
int v_d2 = std::abs(v / 2);
if (v >= -threshold_ && v <= threshold_)
- return value::rgb8(255, 255, 255);
+ return value::rgb8(0, 0, 0);
else if (v > threshold_)
return value::rgb8(v_d2, 128 + v_d2, v_d2);
else
--
1.7.2.5