* z/sauvola_ms_rv/pgm_color_diff.cc,
* z/sauvola_ms_rv/pgm_local_mean.cc,
* z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc: New.
---
scribo/sandbox/ChangeLog | 8 +++
scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc | 60 ++++++++++++++++++++
scribo/sandbox/z/sauvola_ms_rv/pgm_local_mean.cc | 29 ++++++++++
.../z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc | 24 ++++++++
4 files changed, 121 insertions(+), 0 deletions(-)
create mode 100644 scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
create mode 100644 scribo/sandbox/z/sauvola_ms_rv/pgm_local_mean.cc
create mode 100644 scribo/sandbox/z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog
index 8cfe592..446cae0 100644
--- a/scribo/sandbox/ChangeLog
+++ b/scribo/sandbox/ChangeLog
@@ -1,5 +1,13 @@
2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new tools.
+
+ * z/sauvola_ms_rv/pgm_color_diff.cc,
+ * z/sauvola_ms_rv/pgm_local_mean.cc,
+ * z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc: New.
+
+2012-08-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Rename skewness directory and share code between implementations.
* z/skewness/skewness.cc,
diff --git a/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
b/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
new file mode 100644
index 0000000..7474c46
--- /dev/null
+++ b/scribo/sandbox/z/sauvola_ms_rv/pgm_color_diff.cc
@@ -0,0 +1,60 @@
+#include <mln/core/concept/function.hh>
+#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/ppm/save.hh>
+#include <mln/data/transform.hh>
+#include <mln/arith/minus.hh>
+
+namespace mln
+{
+
+ struct color_diff : Function_v2v<color_diff>
+ {
+ typedef value::rgb8 result;
+
+ color_diff(int threshold) : threshold_(threshold) {}
+
+ value::rgb8 operator()(const int& v) const
+ {
+ int v_d2 = std::abs(v / 2);
+
+ if (v >= -threshold_ && v <= threshold_)
+ return value::rgb8(255, 255, 255);
+ else if (v > threshold_)
+ return value::rgb8(v_d2, 128 + v_d2, v_d2);
+ else
+ return value::rgb8(128 + v_d2, v_d2, v_d2);
+ }
+
+
+ int threshold_;
+ };
+
+}
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+
+ if (argc != 5)
+ {
+ std::cout << "Usage: " << argv[0] << " in.pgm
ref.pgm threshold out.ppm" << std::endl;
+ return 1;
+ }
+
+ image2d<value::int_u8> input, ref;
+
+ io::pgm::load(input, argv[1]);
+ io::pgm::load(ref, argv[2]);
+
+ image2d<int> diff = input - ref;
+
+ color_diff f(atoi(argv[3]));
+ image2d<value::rgb8> result = data::transform(diff, f);
+
+ io::ppm::save(result, argv[4]);
+}
diff --git a/scribo/sandbox/z/sauvola_ms_rv/pgm_local_mean.cc
b/scribo/sandbox/z/sauvola_ms_rv/pgm_local_mean.cc
new file mode 100644
index 0000000..06c51e9
--- /dev/null
+++ b/scribo/sandbox/z/sauvola_ms_rv/pgm_local_mean.cc
@@ -0,0 +1,29 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/data/compute_in_window.hh>
+#include <mln/accu/stat/mean.hh>
+#include <mln/win/rectangle2d.hh>
+#include <mln/data/convert.hh>
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc != 4)
+ {
+ std::cout << "Usage: " << argv[0] << " in.pgm
win_size out.pgm" << std::endl;
+ return 1;
+ }
+
+ unsigned win_size = atoi(argv[2]);
+ win::rectangle2d win(win_size, win_size);
+ typedef value::int_u8 V;
+ image2d<V> input;
+ io::pgm::load(input, argv[1]);
+
+ image2d<float> mean = data::compute_in_window(accu::stat::mean<V>(), input,
win);
+
+ io::pgm::save(data::convert(value::int_u8(), mean), argv[3]);
+}
diff --git a/scribo/sandbox/z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc
b/scribo/sandbox/z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc
new file mode 100644
index 0000000..f7b66b7
--- /dev/null
+++ b/scribo/sandbox/z/sauvola_ms_rv/ppm_influence_zone_geodesic.cc
@@ -0,0 +1,24 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/transform/influence_zone_geodesic.hh>
+#include <mln/io/ppm/all.hh>
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc != 3)
+ {
+ std::cout << argv[0] << " input.ppm output.ppm" <<
std::endl;
+ return 1;
+ }
+
+ image2d<value::rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ image2d<value::rgb8> iz = transform::influence_zone_geodesic(input, c8());
+
+ io::ppm::save(iz, argv[2]);
+}
--
1.7.2.5
Show replies by date