Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
September 2009
- 9 participants
- 188 discussions
---
trunk/milena/ChangeLog | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/trunk/milena/ChangeLog b/trunk/milena/ChangeLog
index da1d6c2..21734a8 100644
--- a/trunk/milena/ChangeLog
+++ b/trunk/milena/ChangeLog
@@ -189,6 +189,12 @@
* tests/geom/Makefile.am,
* tests/geom/translate.cc: New test.
+2009-09-15 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix ISO C++ compilation problem : L101.
+
+ * mln/io/plot/load.hh (load) : Update source file.
+
2009-09-14 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Disable tiled2d image support (still experimental).
--
1.5.6.5
1
0
* green/mln/accu/stat/histo3d_hsl.hh (take) : Fix bug.
* green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
(count_histo, mean_histo, var_histo, test_integration): Fix bug.
---
trunk/milena/sandbox/ChangeLog | 17 ++++
.../sandbox/green/mln/accu/stat/histo3d_hsl.hh | 20 ++++-
.../tests/accu/stat/histo3d_hsl/histo3d_hsl.cc | 92 +++++++++++--------
3 files changed, 87 insertions(+), 42 deletions(-)
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index df395ef..06426ad 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -1,3 +1,20 @@
+2009-09-22 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix bug in histo3d_hsl count method.
+
+ * green/mln/accu/stat/histo3d_hsl.hh (take) : Fix bug.
+ * green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
+ (count_histo, mean_histo, var_histo, test_integration): Fix bug.
+
+2009-09-22 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Put the basis of a general gnuplot shell export function.
+
+ * green/mln/io/plot/save_image_sh.hh : New library file.
+ * green/tests/io/plot/save_image_sh : New directory.
+ * green/tests/io/plot/save_image_sh/Makefile : New Makefile.
+ * green/tests/io/plot/save_image_sh/save_image_sh.cc : New unit tests.
+
2009-09-21 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add disk_ima test, improve HSL operations.
diff --git a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
index c8e71ac..f29a725 100644
--- a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
+++ b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
@@ -277,9 +277,23 @@ namespace mln
// mln::trait::value_<argument>::get_comp_0(t);
// is def::coord1d the type of x, y, z ??
- unsigned x = (t.hue() - min_hue)/q;
- unsigned y = (t.lum() - min_lum)/q;
- unsigned z = (t.sat() - min_sat)/q;
+ unsigned x = (t.hue() - min_hue)/step_hue;
+ unsigned y = (t.lum() - min_lum)/step_lum;
+ unsigned z = (t.sat() - min_sat)/step_sat;
+
+
+ std::cout << "H : " << t.hue() << std::endl;
+ std::cout << "L : " << t.lum() << std::endl;
+ std::cout << "S : " << t.sat() << std::endl;
+
+ std::cout << "step_hue : " << step_hue << std::endl;
+ std::cout << "step_lum : " << step_lum << std::endl;
+ std::cout << "step_sat : " << step_sat << std::endl;
+
+ std::cout << "X : " << x << std::endl;
+ std::cout << "Y : " << y << std::endl;
+ std::cout << "Z : " << z << std::endl;
+
// faire attention avec les histoires de points et leurs coordonnées
++count_(point3d(z, x, y));
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
index 27a6b64..47b3900 100644
--- a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
@@ -9,6 +9,7 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/io/pfm/save.hh>
#include <mln/io/plot/save.hh>
#include <mln/data/compute.hh>
@@ -196,18 +197,26 @@ double count_histo(const mln::image3d<unsigned>& img)
return result;
}
-mln::algebra::vec<3,float> conv(const mln::algebra::vec<3,float>& vec)
+mln::algebra::vec<3,float> conv(const mln::algebra::vec<3,float>& vec,
+ const unsigned q)
{
mln::algebra::vec<3,float> result;
- result[0] = vec[2];
- result[1] = vec[0];
- result[2] = vec[1];
+ /*
+ result[0] = vec[2] * (360.0/q);
+ result[1] = vec[0] * (1.0/q);
+ result[2] = vec[1] * (1.0/q);
+ */
+
+ result[0] = (vec[0]+0.5) * (360.0/q);
+ result[1] = (vec[1]+0.5) * (1.0/q);
+ result[2] = (vec[2]+0.5) * (1.0/q);
return result;
}
-mln::algebra::vec<3,float> mean_histo(const mln::image3d<unsigned>& img)
+mln::algebra::vec<3,float> mean_histo(const mln::image3d<unsigned>& img,
+ const unsigned q)
{
mln_precondition(img.is_valid());
typedef mln::algebra::vec<3,float> vec3f;
@@ -220,7 +229,7 @@ mln::algebra::vec<3,float> mean_histo(const mln::image3d<unsigned>& img)
for_all(p)
{
count += img(p);
- sum += conv((vec3f)p) * img(p);
+ sum += conv((vec3f)p, q) * img(p);
}
result = sum / count;
@@ -252,21 +261,22 @@ double var_histo(const mln::image3d<unsigned>& img)
return result;
}
-mln::algebra::mat<3,3,float> var_histo2(const mln::image3d<unsigned>& img)
+mln::algebra::mat<3,3,float> var_histo2(const mln::image3d<unsigned>& img,
+ const unsigned q)
{
mln_precondition(img.is_valid());
typedef mln::algebra::vec<3,float> vec3f;
typedef mln::algebra::mat<3,3,float> mat3f;
double count = count_histo(img);
- vec3f mean = mean_histo(img);
+ vec3f mean = mean_histo(img,q);
vec3f point;
mat3f result = mln::literal::zero;
mln_piter_(mln::image3d<unsigned>) p(img.domain());
for_all(p)
{
- point = conv((vec3f)p) - mean;
+ point = conv((vec3f)p, q) - mean;
result += img(p) * (point * point.t());
}
@@ -287,26 +297,19 @@ hslf_2_vec3f::operator()(const mln::value::hsl_f& hsl) const
return mln::make::vec(hsl.hue(), hsl.lum(), hsl.sat());
}
-
-template <typename A, typename I, typename F>
-mln_result(A)
-compute(mln::Accumulator<A>& a_,
- const mln::Image<I>& input_,
- const mln::Function_v2v<F>& fn_)
+struct hslf_2_h : public mln::Function_v2v< hslf_2_h >
{
- A& a = exact(a_);
- const I& input = exact(input_);
- const F& fn = exact(fn_);
-
- mln_piter(I) p(input.domain());
- for_all(p)
- a.take(fn(input(p)));
+ typedef float result;
+ result operator()(const mln::value::hsl_f& hsl) const;
+};
- return a.result();
+float
+hslf_2_h::operator()(const mln::value::hsl_f& hsl) const
+{
+ return hsl.hue();
}
-
-template <unsigned n>
+template <unsigned n, unsigned q>
void test_integration()
{
typedef mln::value::rgb8 rgb8;
@@ -314,31 +317,41 @@ void test_integration()
typedef mln::value::hsl_f hsl_f;
typedef mln::algebra::vec<3,float> vec3f;
typedef mln::algebra::mat<3,3,float> mat3f;
- typedef mln::accu::math::count<hsl_f> count;
- typedef mln::accu::math::sum<hsl_f,vec3f> sum;
- typedef mln::accu::stat::mean<hsl_f,vec3f,vec3f> mean;
+ typedef mln::accu::math::count<vec3f> count;
+ typedef mln::accu::math::sum<vec3f,vec3f> sum;
+ typedef mln::accu::stat::mean<vec3f,vec3f,vec3f> mean;
typedef mln::accu::stat::var<vec3f> var;
mln::image2d<rgb8> img_fst;
mln::image2d<rgbn> img_sec;
- mln::image2d<hsl_f> img_ref;
+ mln::image2d<hsl_f> img_thd;
+ mln::image2d<vec3f> img_ref;
mln::image3d<unsigned> img_res;
- mln::io::ppm::load(img_fst, OLENA_IMG_PATH"/lena.ppm");
+ mln::image2d<float> img_sav;
+
+ //mln::io::ppm::load(img_fst, OLENA_IMG_PATH"/lena.ppm")
+ mln::io::ppm::load(img_fst, OLENA_IMG_PATH"/fly.ppm");
img_sec = mln::data::transform(img_fst, mln::fun::v2v::rgb8_to_rgbn<n>());
- img_ref = mln::data::transform(img_sec,mln::fun::v2v::f_rgb_to_hsl_<hsl_f>());
+ img_thd = mln::data::transform(img_sec,mln::fun::v2v::f_rgb_to_hsl_<hsl_f>());
+
+ img_sav = mln::data::transform(img_thd, hslf_2_h());
+ mln::io::plot::save_histo_sh(img_sav, "fly2.sh");
- const double count_ref = compute(count(), img_ref, hslf_2_vec3f());
+ img_ref = mln::data::transform(img_thd, hslf_2_vec3f());
+
+ const double count_ref = mln::data::compute(count(), img_ref);
// const vec3f sum_ref = mln::data::compute(sum(), img_ref);
- const vec3f mean_ref = compute(mean(), img_ref, hslf_2_vec3f());
- const mat3f var_ref = compute(var(), img_ref, hslf_2_vec3f());
-
- img_res = mln::data::compute(mln::accu::stat::histo3d_hsl<n,hsl_f>(),img_ref);
+ const vec3f mean_ref = mln::data::compute(mean(), img_ref);
+ const mat3f var_ref = mln::data::compute(var(), img_ref);
+ img_res = mln::data::compute(mln::accu::stat::histo3d_hsl<q,hsl_f>(),img_thd);
+
+ mln::io::plot::save_histo_sh(img_res, "fly3.sh");
const double count_res = count_histo(img_res);
- const vec3f mean_res = mean_histo(img_res);
- const mat3f var_res = var_histo2(img_res);
+ const vec3f mean_res = mean_histo(img_res, q);
+ const mat3f var_res = var_histo2(img_res, q);
std::cout << "count_ref : " << count_ref << std::endl;
std::cout << "mean_ref : " << mean_ref << std::endl;
@@ -350,6 +363,7 @@ void test_integration()
mln_assertion(count_ref == count_res);
+
/*
mln_assertion(0.0001 > abs(mean_ref[0] - mean_res[0]));
mln_assertion(0.0001 > abs(mean_ref[1] - mean_res[1]));
@@ -402,7 +416,7 @@ int main()
test_initialization<3>();
test_take_argument<3>();
test_take_other<3>();
- test_integration<3>();
+ test_integration<3,7>();
return 0;
}
--
1.5.6.5
1
0
22 Sep '09
* green/mln/io/plot/save_image_sh.hh : New library file.
* green/tests/io/plot/save_image_sh : New directory.
* green/tests/io/plot/save_image_sh/Makefile : New Makefile.
* green/tests/io/plot/save_image_sh/save_image_sh.cc : New unit tests.
---
trunk/milena/sandbox/ChangeLog | 14 -
.../sandbox/green/mln/io/plot/save_image_sh.hh | 856 ++++++++++++++++++++
.../green/tests/io/plot/save_image_sh/Makefile.am | 148 ++++
.../tests/io/plot/save_image_sh/save_image_sh.cc | 662 +++++++++++++++
4 files changed, 1666 insertions(+), 14 deletions(-)
create mode 100644 trunk/milena/sandbox/green/mln/io/plot/save_image_sh.hh
create mode 100644 trunk/milena/sandbox/green/tests/io/plot/save_image_sh/Makefile.am
create mode 100644 trunk/milena/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index 944d3af..df395ef 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -54,20 +54,6 @@
starting from (0,0).
Initialize image extension correctly.
-2009-09-15 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
-
- Fix bug in histo3d_rgb (parameters'order in Point's constructor)
-
- * green/mln/accu/stat/histo3d_hsl.hh
- (take) : Fix point's call.
- * green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
- (conv) : Delete func.
- * green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
- (mean_histo, var_histo2) : Update func.
-
- * green/mln/io/plot/save_histo_sh.hh : .
- * green/mln/io/plot/save_image_sh.hh : New library file.
-
2009-09-14 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Fix bug in histo3d_rgb (parameters'order in Point's constructor)
diff --git a/trunk/milena/sandbox/green/mln/io/plot/save_image_sh.hh b/trunk/milena/sandbox/green/mln/io/plot/save_image_sh.hh
new file mode 100644
index 0000000..62f6652
--- /dev/null
+++ b/trunk/milena/sandbox/green/mln/io/plot/save_image_sh.hh
@@ -0,0 +1,856 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_IO_PLOT_SAVE_IMAGE_SH_HH
+#define MLN_IO_PLOT_SAVE_IMAGE_SH_HH
+
+/// \file
+///
+/// \brief Define some functions to export to gnuplot format as a script shell.
+///
+/// Theses routines are dedicated to image visualization. The aim is to display
+/// image whatever the value used as pixel. The behaviour of gnuplot is more
+/// like xv than imageMagick. A Gnuplot script shell file is a text dump file
+/// with a preambule to let gnuplot interpret data. As a script shell, you can
+/// launch it (don't forget the permissions), and every thing is packed in it.
+/// The script file call gnuplot in batch mode, the result window persists and
+/// that's all.
+///
+
+#include <fstream>
+#include <string>
+
+#include <mln/trace/entering.hh>
+#include <mln/trace/exiting.hh>
+#include <mln/core/macros.hh>
+#include <mln/core/contract.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/geom/min_row.hh>
+#include <mln/geom/max_row.hh>
+#include <mln/geom/min_col.hh>
+#include <mln/geom/max_col.hh>
+#include <mln/value/int_u.hh>
+#include <mln/value/int_s.hh>
+#include <mln/value/rgb.hh>
+#include <mln/value/hsl.hh>
+#include <mln/value/hsi.hh>
+
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace plot
+ {
+
+ /// \brief Save an image as a gnuplot script shell.
+ ///
+ /// Every thing is save. The image could be 1d, 2d or 3d. The value of
+ /// the pixels could be int_u<n>, int_s<n>, float, double, hsl_f, hsl_d,
+ /// hsi_f, hsi_d and rgb<n>.
+ ///
+ /// \param[in] img the image which contains the data to save.
+ /// \param[in] filename the name of the unix script shell.
+ /// \return the status of the opening file operation.
+ ///
+ /// The result depends on the permission to save the file with
+ /// filename parameter as unix path. The script shell file must have the
+ /// permission to execute (chmod 755). Launch the script shell to call
+ /// gnuplot in batchmode with fine parameters.
+
+ template <typename I>
+ bool save_image_sh(const Image<I>& img, const std::string& filename);
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+
+ namespace io
+ {
+
+ namespace plot
+ {
+
+#ifndef MLN_INCLUDE_ONLY
+
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<bool>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ inline
+ bool save_image_sh_dispatch_overload(const image2d< bool >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<bool>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter_(image2d< bool >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, bool) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using (\\$2):(-\\$1):(\\$3) with image" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<bool>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<float>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ inline
+ bool save_image_sh_dispatch_overload(const image2d<float>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<float>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter_(image2d< float >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, float) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using (\\$2):(-\\$1):(\\$3) with image" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<float>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<double>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ inline
+ bool save_image_sh_dispatch_overload(const image2d<double>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<double>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter_(image2d< double >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, double) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using (\\$2):(-\\$1):(\\$3) with image" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<double>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<int_u<n>>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <unsigned n>
+ inline
+ bool save_image_sh_dispatch_overload(const image2d<value::int_u<n> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<int_u<n>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter(image2d< value::int_u<n> >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, int_u<n>) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using (\\$2):(-\\$1):(\\$3) with image" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<int_u<n>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<int_s<n>>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <unsigned n>
+ inline
+ bool save_image_sh_dispatch_overload(const image2d<value::int_s<n> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<int_s<n>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter(image2d< value::int_s<n> >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, int_s<n>) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using 2:(-\\$1):3 with image" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<int_s<n>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<rgb<n>>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <unsigned n>
+ inline
+ bool save_image_sh_dispatch_overload(const image2d<value::rgb<n> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<rgb<n>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter(image2d< value::int_u<n> >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, r, g, b) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using 2:(-\\$1):3:4:5 with rgbimage" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p).red() << " ";
+ out << img(p).green() << " ";
+ out << img(p).blue() << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<rgb<n>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<hsl_<T,T,T>>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <typename T>
+ inline
+ bool save_image_sh(const image2d<mln::value::hsl_<T,T,T> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<hsl>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ typedef mln::value::hsl_<T,T,T> hsl;
+
+ if (result)
+ {
+ mln_piter(image2d< hsl >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, val) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "q(l,s) = (l < 0.5)? (l*(1+s)) : (l+s-(l*s))" << std::endl;
+ out << "p(l,s) = (2.0 * l - q(l,s))" << std::endl;
+ out << "n(x) = (x < 0)?(x+1) : (x > 1)?(x-1) : (x)"<< std::endl;
+ out << std::endl;
+ out << "c(p,q,t) = (t < (1.0/6.0))?(p+(q-p)*6.0*t):\\" << std::endl;
+ out << " (t < (1.0/2.0))?(q) :\\" << std::endl;
+ out << " (t < (2.0/3.0))?(p+(q-p)*6.0*((2.0/3.0)-t)):\\" << std::endl;
+ out << " (p)" << std::endl;
+ out << std::endl;
+ out << "r(h,s,l) = c(p(l,s),q(l,s),n(h/360.0+1.0/3.0))"<< std::endl;
+ out << "g(h,s,l) = c(p(l,s),q(l,s),n(h/360.0))" << std::endl;
+ out << "b(h,s,l) = c(p(l,s),q(l,s),n(h/360.0-1.0/3.0))"<< std::endl;
+ out << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using 2:(-\\$1):(r(\\$3,\\$4,\\$5)):\\" << std::endl;
+ out << " (g(\\$3,\\$4,\\$5)):\\" << std::endl;
+ out << " (b(\\$3,\\$4,\\$5)) with rgbimage"<< std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p).hue() << " ";
+ out << img(p).sat() << " ";
+ out << img(p).lum() << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<hsl>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<hsi_<T,T,T>>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <typename T>
+ inline
+ bool save_image_sh(const image2d<mln::value::hsi_<T,T,T> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<2d>vf");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ typedef mln::value::hsi_<T,T,T> hsi;
+
+ if (result)
+ {
+ mln_piter(image2d< hsi >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, val) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "teta(h) = (h/180.0) * pi" << std::endl;
+ out << "alpha(s,h) = s*cos(teta(h))" << std::endl;
+ out << "beta(s,h) = s*sin(teta(h))" << std::endl;
+ out << "n(x) = (x < 0)?(x+1) : (x > 1)?(x-1) : (x)"<< std::endl;
+ out << std::endl;
+ out << "c(p,q,t) = (t < (1.0/6.0))?(p+(q-p)*6.0*t):\\" << std::endl;
+ out << " (t < (1.0/2.0))?(q) :\\" << std::endl;
+ out << " (t < (2.0/3.0))?(p+(q-p)*6.0*((2.0/3.0)-t)):\\" << std::endl;
+ out << " (p)" << std::endl;
+ out << std::endl;
+ out << "r(h,s,i) = (sqrt(3.0)/3.0) * i \\" << std::endl;
+ out << " + (2.0/(sqrt(6.0))) * beta(s,h)" << std::endl;
+ out << "g(h,s,i) = (sqrt(3.0)/3.0) * i \\" << std::endl;
+ out << " + (2.0/(sqrt(2.0))) * alpha(s,h) \\"<< std::endl;
+ out << " - (1.0/(sqrt(6.0))) * beta(s,h)" << std::endl;
+ out << "b(h,s,i) = (sqrt(3.0)/3.0) * i \\" << std::endl;
+ out << " - (2.0/(sqrt(2.0))) * alpha(s,h) \\"<< std::endl;
+ out << " - (1.0/(sqrt(6.0))) * beta(s,h)" << std::endl;
+ out << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set palette gray" << std::endl;
+ out << "set xrange [" << min_col;
+ out << ":" << max_col;
+ out << "]" << std::endl;
+ out << "set yrange [-" << max_row;
+ out << ":" << min_row;
+ out << "]" << std::endl;
+ out << "plot '-' using 2:(-\\$1):(r(\\$3,\\$4,\\$5)):\\" << std::endl;
+ out << " (g(\\$3,\\$4,\\$5)):\\" << std::endl;
+ out << " (b(\\$3,\\$4,\\$5)) with rgbimage"<< std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p).hue() << " ";
+ out << img(p).sat() << " ";
+ out << img(p).inty() << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" << filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<2d>vf");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image2d<I>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch_overload(const image2d<I>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image2d<I>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+
+ if (result)
+ {
+ mln_piter(image2d<I>) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, builtin) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "set pm3d" << std::endl;
+ out << "set dgrid3d 20,20,2" << std::endl;
+ out << "splot '-' with lines" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.col() << " ";
+ out << p.row() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:"<< filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image2d<I>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image1d<I>&, const std::string&)
+ //------------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch_overload(const image1d<I>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image1d<I>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+
+ if (result)
+ {
+ mln_piter(image1d<I>) p(img.domain());
+
+ // Output data prelude (terminal X11, impulse).
+ out << "#!/bin/sh" << std::endl;
+ out << "##########################" << std::endl;
+ out << "# Two columns = (x, val) #" << std::endl;
+ out << "##########################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "plot '-' with impulse" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.ind() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:"<< filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image1d<I>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // save_image_sh(const image3d<I>&, const std::string&)
+ //------------------------------------------------------------------------
+
+
+ template <typename I>
+ inline
+ bool save_image_sh(const image3d<I>& img, const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh<image3d<I>>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+
+ if (result)
+ {
+ mln_piter(image3d<I>) p(img.domain());
+
+ // Output data prelude (terminal X11, pointtype 0).
+ out << "#!/bin/sh" << std::endl;
+ out << "####################################" << std::endl;
+ out << "# Columns = (x, y, z, val) #" << std::endl;
+ out << "####################################" << std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" << std::endl;
+ out << "set terminal x11 persist 1" << std::endl;
+ out << "splot '-' with points palette pointtype 7" << std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << p.sli() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:"<< filename;
+ std::cerr << " couldn't be opened !!" << std::endl;
+ }
+
+ trace::exiting("mln::io::plot::save_image_sh<image3d<I>>");
+ return result;
+ }
+
+ //------------------------------------------------------------------------
+ // Facade.
+ //------------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const Image<I>& img,
+ const std::string& filename)
+ {
+ return save_image_sh_dispatch_overload(exact(img), filename);
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh(const Image<I>& img, const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh");
+
+ bool result = save_image_sh_dispatch(img, filename);
+
+ trace::exiting("mln::io::plot::save_image_sh");
+ return result;
+ }
+
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+#endif // ! MLN_IO_PLOT_SAVE_IMAGE_SH_HH
diff --git a/trunk/milena/sandbox/green/tests/io/plot/save_image_sh/Makefile.am b/trunk/milena/sandbox/green/tests/io/plot/save_image_sh/Makefile.am
new file mode 100644
index 0000000..d970989
--- /dev/null
+++ b/trunk/milena/sandbox/green/tests/io/plot/save_image_sh/Makefile.am
@@ -0,0 +1,148 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+ECHO= echo
+RM= rm
+MKDIR= mkdir -p
+CP= cp
+
+SOURCE_PATTERN= green/tests
+BUILD__PATTERN= green/build/tests
+
+
+ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
+# Case where make is done from build directory.
+SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
+BUILD__DIR= $(PWD)
+else
+# Case where make is done from source directory.
+SOURCE_DIR= $(PWD)
+BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
+endif
+
+SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
+OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
+OBJ= $(patsubst %.cc,%.o,$(SRC))
+SOURCE_MAKEFILE=Makefile.am
+BUILD__MAKEFILE=Makefile
+TARGET_FILE= $(notdir $(PWD))
+SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
+BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
+
+BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
+SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
+
+BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
+SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
+
+TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
+OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
+SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
+OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
+
+#############
+# BOOTSTRAP #
+#############
+
+
+bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
+
+# Create, if nessary, the destination directory
+$(BUILD__DIR):
+ $(MKDIR) $(BUILD__DIR)
+
+# Copy, if nessary, all the files, except the Makefile.am
+$(BUILD__F_PATH): $(SOURCE_F_PATH)
+ $(CP) $(addprefix $(SOURCE_DIR)/,$(@F)) $@
+
+# Copy if nessary, the Makefile.am into Makefile
+$(BUILD__M_PATH): $(SOURCE_M_PATH)
+ $(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
+
+
+#######
+# ALL #
+#######
+
+# We assume that the call is done from the build directory.
+# With the directive vpath, hidden files are found in the source directory.
+
+all: $(TARGET_F_PATH)
+
+
+$(TARGET_F_PATH): $(OBJ_F_PATH)
+ $(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
+
+$(OBJ_F_PATH):$(SRC_F_PATH)
+ $(COMPILE.cc) $(OUTPUT_OPTION) $<
+
+
+#########
+# CLEAN #
+#########
+
+# Force every time the deletion
+clean: clean_target clean_obj clean_dst clean_old #clean_make
+
+
+clean_target:
+ -@$(RM) $(TARGET_F_PATH) &> /dev/null
+
+clean_obj:
+ -@$(RM) $(OBJ_F_PATH) &> /dev/null
+
+clean_dst:
+ -@$(RM) $(BUILD_F_PATH) &> /dev/null
+
+clean_make:
+ -@$(RM) $(BUILD_M_PATH) &> /dev/null
+
+clean_old:
+ -@$(RM) $(OLD_F_PATH) &> /dev/null
+
+
+#########
+# PRINT #
+#########
+
+print: print_tools print_bootstrap
+
+print_tools:
+ @$(ECHO) "HOME = $(HOME)"
+ @$(ECHO) "INCLUDES = $(INCLUDES)"
+ @$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
+ @$(ECHO) "ECHO = $(ECHO)"
+ @$(ECHO) "RM = $(RM)"
+ @$(ECHO) "MKDIR = $(MKDIR)"
+ @$(ECHO) "CP = $(CP)"
+ @$(ECHO)
+
+print_bootstrap:
+ @$(ECHO) "PWD = $(PWD)"
+ @$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
+ @$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
+ @$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
+ @$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
+ @$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
+ @$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
+ @$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
+ @$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
+ @$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
+ @$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
+ @$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
+ @$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
+ @$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
+ @$(ECHO) "SRC = $(SRC)"
+ @$(ECHO) "OBJ = $(OBJ)"
+ @$(ECHO) "OLD = $(OLD)"
+ @$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
+ @$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
+ @$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
+ @$(ECHO)
diff --git a/trunk/milena/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc b/trunk/milena/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc
new file mode 100644
index 0000000..c9c817b
--- /dev/null
+++ b/trunk/milena/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc
@@ -0,0 +1,662 @@
+/// TEST SAVE_IMAGE_SH.HH
+
+#include <iostream>
+#include <limits.h>
+
+#include <mln/img_path.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/int_s8.hh>
+#include <mln/value/int_s16.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb16.hh>
+#include <mln/value/hsl.hh>
+#include <mln/value/hsi.hh>
+#include <mln/util/array.hh>
+#include <mln/core/macros.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/fun/v2v/rgb_to_hsl.hh>
+#include <mln/fun/v2v/rgb_to_hsi.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pgms/load.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/plot/save_image_sh.hh>
+#include <mln/io/plot/load.hh>
+
+#include <mln/data/transform.hh>
+#include <mln/literal/colors.hh>
+#include <mln/debug/println.hh>
+
+//------------------------------------------------------------------------------
+// TEST TO SAVE UNSIGNED 8 BITS 1D GRAYSCALE IMAGE
+//------------------------------------------------------------------------------
+
+mln::image1d<mln::value::int_u8>
+convert_array_to_image1d(const mln::util::array<mln::value::int_u8>& array)
+{
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::image1d<int_u8> image1d;
+ typedef mln::util::array<int_u8> array1d;
+
+ image1d result(array.nelements());
+
+ mln_piter_(image1d) p(result.domain());
+ mln_eiter_(array1d) e(array);
+
+ for_all_2(e, p)
+ {
+ result(p) = e.element();
+ }
+
+ return result;
+}
+
+void test_save_image_sh_1d()
+{
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::image1d<int_u8> image1d;
+ typedef mln::util::array<int_u8> array1d;
+
+ image1d img;
+ array1d array;
+
+ mln::io::plot::load(array, OLENA_IMG_PATH"/fly.plot");
+ img = convert_array_to_image1d(array);
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img, "/dev/null/fly.sh");
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img, "fly1d.sh");
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image 1d : ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<bool>
+//------------------------------------------------------------------------------
+
+
+void test_save_image2d_bool()
+{
+ typedef mln::image2d<bool> image2d_bool;
+ const char* null_lena = "/dev/null/lena2d_bool.sh";
+ const char* lena = "lena2d_bool.sh";
+
+ image2d_bool img_bool;
+
+ mln::io::pbm::load(img_bool, OLENA_IMG_PATH"/lena.pbm");
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_bool, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_bool, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<bool>: ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<int_u8>
+//------------------------------------------------------------------------------
+
+
+void test_save_image2d_int_u8()
+{
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::image2d<int_u8> image2d_int_u8;
+ const char* null_lena = "/dev/null/lena2d_int_u8.sh";
+ const char* lena = "lena2d_int_u8.sh";
+
+ image2d_int_u8 img_int_u8;
+
+ mln::io::pgm::load(img_int_u8, OLENA_IMG_PATH"/lena.pgm");
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_int_u8, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_int_u8, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<int_u8>: ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<int_u16>
+//------------------------------------------------------------------------------
+
+struct int_u16_to_int_u8 : mln::Function_v2v< int_u16_to_int_u8 >
+{
+ typedef mln::value::int_u16 argument;
+ typedef mln::value::int_u8 result;
+
+ result operator()(const argument& c) const
+ {
+ result res(c / 256);
+
+ return res;
+ }
+};
+
+void test_save_image2d_int_u16()
+{
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::value::int_u16 int_u16;
+ typedef mln::image2d<int_u8> image2d_int_u8;
+ typedef mln::image2d<int_u16> image2d_int_u16;
+ const char* null_lena = "/dev/null/lena2d_int_u16.sh";
+ const char* lena = "lena2d_int_u16.sh";
+
+ image2d_int_u8 img_int_u8;
+ image2d_int_u16 img_int_u16;
+
+ mln::io::pgm::load(img_int_u16, OLENA_IMG_PATH"/lena_16_gnuplot.pgm");
+ //img_int_u8 = mln::data::transform(img_int_u16, int_u16_to_int_u8());
+ //mln::io::pgm::save(img_int_u8, "lena_8.pgm");
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_int_u16, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_int_u16, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<int_u16> : ok" << std::endl;
+}
+
+
+//------------------------------------------------------------------------------
+// Test to save image2d<int_s8>
+//------------------------------------------------------------------------------
+
+struct int_u8_to_int_s8 : mln::Function_v2v< int_u8_to_int_s8 >
+{
+ typedef mln::value::int_u8 argument;
+ typedef mln::value::int_s8 result;
+
+ result operator()(const argument& c) const
+ {
+ argument tmp_int_u8;
+ result tmp_int_s8;
+ result res;
+
+ // Note : -127 <= int_s8 <= +127
+ if (UCHAR_MAX == c)
+ {
+ res = SCHAR_MAX;
+ }
+ else if (SCHAR_MAX < c)
+ {
+ tmp_int_u8 = c - SCHAR_MAX;
+ res = static_cast<mln::value::int_s8>(tmp_int_u8);
+ }
+ else
+ {
+ tmp_int_s8 = static_cast<mln::value::int_s8>(c) - SCHAR_MAX;
+ res = tmp_int_s8;
+ }
+
+ return res;
+ }
+};
+
+
+void test_save_image2d_int_s8()
+{
+ typedef mln::value::int_s8 int_s8;
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::image2d<int_s8> image2d_int_s8;
+ typedef mln::image2d<int_u8> image2d_int_u8;
+ const char* null_lena = "/dev/null/lena2d_int_s8.sh";
+ const char* lena = "lena2d_int_s8.sh";
+
+ image2d_int_s8 img_int_s8;
+ image2d_int_u8 img_int_u8;
+
+ mln::io::pgm::load(img_int_u8, OLENA_IMG_PATH"/lena.pgm");
+ img_int_s8 = mln::data::transform(img_int_u8, int_u8_to_int_s8());
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_int_s8, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_int_s8, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<int_s8>: ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<int_s16>
+//------------------------------------------------------------------------------
+
+struct int_u16_to_int_s16 : mln::Function_v2v< int_u16_to_int_s16 >
+{
+ typedef mln::value::int_u16 argument;
+ typedef mln::value::int_s16 result;
+
+ result operator()(const argument& c) const
+ {
+ argument tmp_int_u16;
+ result tmp_int_s16;
+ result res;
+
+ if (USHRT_MAX == c)
+ {
+ res = SHRT_MAX;
+ }
+ else if (SHRT_MAX < c)
+ {
+ tmp_int_u16 = c - SHRT_MAX;
+ res = static_cast<mln::value::int_s16>(tmp_int_u16);
+ }
+ else
+ {
+ tmp_int_s16 = static_cast<mln::value::int_s16>(c) - SHRT_MAX;
+ res = tmp_int_s16;
+ }
+
+ return res;
+ }
+};
+
+void test_save_image2d_int_s16()
+{
+ typedef mln::value::int_u16 int_u16;
+ typedef mln::value::int_s16 int_s16;
+ typedef mln::image2d<int_s16> image2d_int_s16;
+ typedef mln::image2d<int_u16> image2d_int_u16;
+ const char* null_lena = "/dev/null/lena2d_int_s16.sh";
+ const char* lena = "lena2d_int_s16.sh";
+
+ image2d_int_s16 img_int_s16;
+ image2d_int_u16 img_int_u16;
+
+ mln::io::pgm::load(img_int_u16, OLENA_IMG_PATH"/lena_16_gnuplot.pgm");
+ img_int_s16 = mln::data::transform(img_int_u16, int_u16_to_int_s16());
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_int_s16, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_int_s16, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<int_s16> : ok" << std::endl;
+}
+
+
+//------------------------------------------------------------------------------
+// Test to save image2d<float>
+//------------------------------------------------------------------------------
+
+struct int_u8_to_float : mln::Function_v2v< int_u8_to_float >
+{
+ typedef mln::value::int_u8 argument;
+ typedef float result;
+
+ result operator()(const argument& c) const
+ {
+ result res = static_cast<float>(c)/3;
+
+ return res;
+ }
+};
+
+void test_save_image2d_float()
+{
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::image2d<float> image2d_float;
+ typedef mln::image2d<int_u8> image2d_int_u8;
+ const char* null_lena = "/dev/null/lena2d_float.sh";
+ const char* lena = "lena2d_float.sh";
+
+ image2d_int_u8 img_int_u8;
+ image2d_float img_float;
+
+ mln::io::pgm::load(img_int_u8, OLENA_IMG_PATH"/lena.pgm");
+ img_float = mln::data::transform(img_int_u8, int_u8_to_float());
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_float, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_float, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<float> : ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<double>
+//------------------------------------------------------------------------------
+
+struct int_u16_to_double : mln::Function_v2v< int_u16_to_double >
+{
+ typedef mln::value::int_u16 argument;
+ typedef double result;
+
+ result operator()(const argument& c) const
+ {
+ result res = static_cast<float>(c)/256;
+
+ return res;
+ }
+};
+
+void test_save_image2d_double()
+{
+ typedef mln::value::int_u16 int_u16;
+ typedef mln::image2d<double> image2d_double;
+ typedef mln::image2d<int_u16> image2d_int_u16;
+ const char* null_lena = "/dev/null/lena2d_double.sh";
+ const char* lena = "lena2d_double.sh";
+
+ image2d_int_u16 img_int_u16;
+ image2d_double img_double;
+
+ mln::io::pgm::load(img_int_u16, OLENA_IMG_PATH"/lena_16_gnuplot.pgm");
+ img_double = mln::data::transform(img_int_u16, int_u16_to_double());
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_double, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_double, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<double> : ok" << std::endl;
+}
+
+
+
+//------------------------------------------------------------------------------
+// Test to save image2d<rgb8>
+//------------------------------------------------------------------------------
+
+void test_save_image2d_rgb8()
+{
+ typedef mln::value::rgb8 rgb8;
+ typedef mln::image2d<rgb8> image2d_rgb8;
+ const char* null_lena = "/dev/null/lena2d_rgb8.sh";
+ const char* lena = "lena2d_rgb8.sh";
+
+ image2d_rgb8 img_rgb8;
+
+ mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_rgb8, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_rgb8, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<rgb8> : ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<rgb16>
+//------------------------------------------------------------------------------
+
+struct rgb16_to_int_u16 : mln::Function_v2v< rgb16_to_int_u16 >
+{
+ typedef mln::value::rgb16 argument;
+ typedef mln::value::int_u16 result;
+
+
+ result operator()(const argument& c) const
+ {
+ result res((c.red() + c.green() + c.blue())/3);
+
+ return res;
+ }
+};
+
+void test_save_image2d_rgb16()
+{
+ typedef mln::value::rgb16 rgb16;
+ typedef mln::value::int_u16 int_u16;
+ typedef mln::image2d<rgb16> image2d_rgb16;
+ typedef mln::image2d<int_u16> image2d_int_u16;
+ const char* null_lena = "/dev/null/lena2d_rgb16.sh";
+ const char* lena = "lena2d_rgb16.sh";
+ //const char* lena2 = "lena2d_int_u16.sh";
+
+
+ image2d_rgb16 img_rgb16;
+ image2d_int_u16 img_int_u16;
+
+ mln::io::ppm::load(img_rgb16, OLENA_IMG_PATH"/lena_16.ppm");
+ //img_int_u16 = mln::data::transform(img_rgb16, rgb16_to_int_u16());
+ //mln::io::pgm::save(img_int_u16, "lena_16.pgm");
+
+ // Save it were it is impossible to do it !!
+ bool ref_false=mln::io::plot::save_image_sh(img_rgb16, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_rgb16, lena);
+ // mln::io::plot::save_image_sh(img_int_u16, lena2);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<rgb16> : ok" << std::endl;
+}
+
+
+//------------------------------------------------------------------------------
+// Test to save image2d<hsl_f>
+//------------------------------------------------------------------------------
+
+void test_save_image2d_hsl_f()
+{
+ typedef mln::value::hsl_f hsl_f;
+ typedef mln::value::rgb8 rgb8;
+ typedef mln::image2d<hsl_f> image2d_hsl_f;
+ typedef mln::image2d<rgb8> image2d_rgb8;
+ typedef mln::fun::v2v::f_rgb_to_hsl_<hsl_f> rgb_to_hsl;
+
+ const char* null_lena = "/dev/null/lena2d_hsl_f.sh";
+ const char* lena = "lena2d_hsl_f.sh";
+ image2d_hsl_f img_hsl_f;
+ image2d_rgb8 img_rgb8;
+
+ mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+ //mln::data::fill(img_rgb8, mln::literal::red);
+ //mln::data::fill(img_rgb8, mln::literal::green);
+ //mln::data::fill(img_rgb8, mln::literal::blue);
+ img_hsl_f = mln::data::transform(img_rgb8, rgb_to_hsl());
+
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_hsl_f, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_hsl_f, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<hsl_f> : ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<hsl_d>
+//------------------------------------------------------------------------------
+
+void test_save_image2d_hsl_d()
+{
+ typedef mln::value::hsl_d hsl_d;
+ typedef mln::value::rgb16 rgb16;
+ typedef mln::image2d<hsl_d> image2d_hsl_d;
+ typedef mln::image2d<rgb16> image2d_rgb16;
+ typedef mln::fun::v2v::f_rgb_to_hsl_<hsl_d> rgb_to_hsl;
+
+ const char* null_lena = "/dev/null/lena2d_hsl_d.sh";
+ const char* lena = "lena2d_hsl_d.sh";
+ image2d_hsl_d img_hsl_d;
+ image2d_rgb16 img_rgb16;
+
+ mln::io::ppm::load(img_rgb16, OLENA_IMG_PATH"/lena_16.ppm");
+ //mln::data::fill(img_rgb16, mln::literal::red);
+ //mln::data::fill(img_rgb16, mln::literal::green);
+ //mln::data::fill(img_rgb16, mln::literal::blue);
+ img_hsl_d = mln::data::transform(img_rgb16, rgb_to_hsl());
+
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_hsl_d, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_hsl_d, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<hsl_d> : ok" << std::endl;
+}
+
+
+//------------------------------------------------------------------------------
+// Test to save image2d<hsi_f>
+//------------------------------------------------------------------------------
+
+void test_save_image2d_hsi_f()
+{
+ typedef mln::value::hsi_f hsi_f;
+ typedef mln::value::rgb8 rgb8;
+ typedef mln::image2d<hsi_f> image2d_hsi_f;
+ typedef mln::image2d<rgb8> image2d_rgb8;
+ typedef mln::fun::v2v::f_rgb_to_hsi_<hsi_f> rgb_to_hsi;
+
+ const char* null_lena = "/dev/null/lena2d_hsi_f.sh";
+ const char* lena = "lena2d_hsi_f.sh";
+ image2d_hsi_f img_hsi_f;
+ image2d_rgb8 img_rgb8;
+
+ mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+ //mln::data::fill(img_rgb8, mln::literal::red);
+ //mln::data::fill(img_rgb8, mln::literal::green);
+ //mln::data::fill(img_rgb8, mln::literal::blue);
+ img_hsi_f = mln::data::transform(img_rgb8, rgb_to_hsi());
+
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_hsi_f, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_hsi_f, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<hsi_f> : ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// Test to save image2d<hsi_d>
+//------------------------------------------------------------------------------
+
+void test_save_image2d_hsi_d()
+{
+ typedef mln::value::hsi_d hsi_d;
+ typedef mln::value::rgb16 rgb16;
+ typedef mln::image2d<hsi_d> image2d_hsi_d;
+ typedef mln::image2d<rgb16> image2d_rgb16;
+ typedef mln::fun::v2v::f_rgb_to_hsi_<hsi_d> rgb_to_hsi;
+
+ const char* null_lena = "/dev/null/lena2d_hsi_d.sh";
+ const char* lena = "lena2d_hsi_d.sh";
+ image2d_hsi_d img_hsi_d;
+ image2d_rgb16 img_rgb16;
+
+ mln::io::ppm::load(img_rgb16, OLENA_IMG_PATH"/lena_16.ppm");
+ //mln::data::fill(img_rgb16, mln::literal::red);
+ //mln::data::fill(img_rgb16, mln::literal::green);
+ //mln::data::fill(img_rgb16, mln::literal::blue);
+ img_hsi_d = mln::data::transform(img_rgb16, rgb_to_hsi());
+
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img_hsi_d, null_lena);
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img_hsi_d, lena);
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image2d<hsi_d> : ok" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+// TEST TO SAVE 8 BITS 3D RGB IMAGE
+//------------------------------------------------------------------------------
+
+void test_save_image_sh_3d()
+{
+ typedef mln::value::int_u8 int_u8;
+ typedef mln::image3d<int_u8> image3d;
+ typedef mln::util::array<std::string> array1d;
+
+ image3d img;
+ array1d array;
+
+ for (unsigned i = 0; i < 5; i++)
+ array.append(OLENA_IMG_PATH"/fly.pgm");
+
+ mln::io::pgms::load(img, array);
+
+ // Save it were it is impossible to do it !!
+ bool ref_false = mln::io::plot::save_image_sh(img, "/dev/null/fly3d.sh");
+
+ // Save it where we have the full permissions.
+ bool ref_true = mln::io::plot::save_image_sh(img, "fly3d.sh");
+
+ mln_assertion(true == ref_true);
+ mln_assertion(false == ref_false);
+ std::cout << "save image 3d : ok" << std::endl;
+}
+
+
+int main()
+{
+ test_save_image_sh_1d();
+
+ test_save_image2d_bool();
+
+ test_save_image2d_int_u8();
+ test_save_image2d_int_u16();
+
+ test_save_image2d_int_s8();
+ test_save_image2d_int_s16();
+
+ test_save_image2d_float();
+ test_save_image2d_double();
+
+ test_save_image2d_rgb8();
+ test_save_image2d_rgb16();
+
+ test_save_image2d_hsl_f();
+ test_save_image2d_hsl_d();
+
+ test_save_image2d_hsi_f();
+ test_save_image2d_hsi_d();
+
+ test_save_image_sh_3d();
+
+ return 0;
+}
--
1.5.6.5
1
0
* mln/io/plot/load.hh (load) : Update source file.
---
trunk/milena/mln/io/plot/load.hh | 5 ++++-
trunk/milena/sandbox/ChangeLog | 14 ++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/trunk/milena/mln/io/plot/load.hh b/trunk/milena/mln/io/plot/load.hh
index f13a3b6..2b381e4 100644
--- a/trunk/milena/mln/io/plot/load.hh
+++ b/trunk/milena/mln/io/plot/load.hh
@@ -97,7 +97,10 @@ namespace mln
arr.clear();
std::ifstream file_in(filename.c_str());
- int MAX_LENGTH = 100;
+ // int MAX_LENGTH = 100;
+ // ISO C++ CAN'T COMPILE WITH VARIABLE LENGTH ARRAY !!
+ // THUS MAKE IT CONSTANT
+ const int MAX_LENGTH = 100;
char line[MAX_LENGTH];
char delims[] = " ";
char *result = NULL;
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index df395ef..944d3af 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -54,6 +54,20 @@
starting from (0,0).
Initialize image extension correctly.
+2009-09-15 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix bug in histo3d_rgb (parameters'order in Point's constructor)
+
+ * green/mln/accu/stat/histo3d_hsl.hh
+ (take) : Fix point's call.
+ * green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
+ (conv) : Delete func.
+ * green/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
+ (mean_histo, var_histo2) : Update func.
+
+ * green/mln/io/plot/save_histo_sh.hh : .
+ * green/mln/io/plot/save_image_sh.hh : New library file.
+
2009-09-14 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Fix bug in histo3d_rgb (parameters'order in Point's constructor)
--
1.5.6.5
1
0
22 Sep '09
* green/mln/accu/stat/histo3d_rgb.hh
(take) : Fix point's call.
* green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
(conv) : Delete func.
* green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
(mean_histo, var_histo2) : Update func.
---
trunk/milena/sandbox/ChangeLog | 11 ++++++++++
.../sandbox/green/mln/accu/stat/histo3d_rgb.hh | 3 +-
.../tests/accu/stat/histo3d_rgb/histo3d_rgb.cc | 22 +------------------
3 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index cdf5a60..df395ef 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -56,6 +56,17 @@
2009-09-14 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Fix bug in histo3d_rgb (parameters'order in Point's constructor)
+
+ * green/mln/accu/stat/histo3d_rgb.hh
+ (take) : Fix point's call.
+ * green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
+ (conv) : Delete func.
+ * green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
+ (mean_histo, var_histo2) : Update func.
+
+2009-09-14 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Move stats directory in doc/examples.
* green/doc/examples/stats : New directory.
diff --git a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
index 8a10c0b..461870a 100644
--- a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
+++ b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
@@ -247,7 +247,8 @@ namespace mln
// Just convert a greyscale value (int_u8 like) to a position for an
// iterator on the resulting image.
- ++count_(point3d(t.red(), t.green(), t.blue()));
+ // Take care to the constructor : Point(slice, row, column)
+ ++count_(point3d(t.blue(), t.red(), t.green()));
trace::exiting("mln::accu::stat::histo3d_rgb<V>::take");
}
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
index 114a52d..eb87332 100644
--- a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
@@ -185,17 +185,6 @@ double count_histo(const mln::image3d<unsigned>& img)
return result;
}
-mln::algebra::vec<3,float> conv(const mln::algebra::vec<3,float>& vec)
-{
- mln::algebra::vec<3,float> result;
-
- result[0] = vec[2];
- result[1] = vec[0];
- result[2] = vec[1];
-
- return result;
-}
-
mln::algebra::vec<3,float> mean_histo(const mln::image3d<unsigned>& img)
{
mln_precondition(img.is_valid());
@@ -208,14 +197,8 @@ mln::algebra::vec<3,float> mean_histo(const mln::image3d<unsigned>& img)
for_all(p)
{
- /*
- std::cout << "(1) " << p << std::endl;
- std::cout << "(2) " << (vec3f)p << std::endl;
- std::cout << "(3) " << conv((vec3f)p) << std::endl;
- */
count += img(p);
- sum += conv((vec3f)p) * img(p);
- // sum += p.to_vec() * img(p);
+ sum += p.to_vec() * img(p);
}
result = sum / count;
@@ -261,8 +244,7 @@ mln::algebra::mat<3,3,float> var_histo2(const mln::image3d<unsigned>& img)
for_all(p)
{
- // point = p.to_vec() - mean;
- point = conv((vec3f)p) - mean;
+ point = p.to_vec() - mean;
result += img(p) * (point * point.t());
}
--
1.5.6.5
1
0
* green/doc/examples/stats : New directory.
* green/doc/examples/stats/Makefile.am : Copy makefile.
* green/doc/examples/stats/stats.cc : Copy source file.
* green/stats/stats.cc : Remove source file.
* green/stats/Makefile.am : Remove makefile.
* green/stats : Remove directory.
---
trunk/milena/sandbox/ChangeLog | 12 ++++++++++++
.../green/{ => doc/examples}/stats/Makefile.am | 0
.../green/{ => doc/examples}/stats/stats.cc | 0
3 files changed, 12 insertions(+), 0 deletions(-)
rename trunk/milena/sandbox/green/{ => doc/examples}/stats/Makefile.am (100%)
rename trunk/milena/sandbox/green/{ => doc/examples}/stats/stats.cc (100%)
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index a8ad105..cdf5a60 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -54,6 +54,18 @@
starting from (0,0).
Initialize image extension correctly.
+2009-09-14 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Move stats directory in doc/examples.
+
+ * green/doc/examples/stats : New directory.
+ * green/doc/examples/stats/Makefile.am : Copy makefile.
+ * green/doc/examples/stats/stats.cc : Copy source file.
+
+ * green/stats/stats.cc : Remove source file.
+ * green/stats/Makefile.am : Remove makefile.
+ * green/stats : Remove directory.
+
2009-09-13 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Save work in progress for histo and hsl. Everything is updated.
diff --git a/trunk/milena/sandbox/green/stats/Makefile.am b/trunk/milena/sandbox/green/doc/examples/stats/Makefile.am
similarity index 100%
rename from trunk/milena/sandbox/green/stats/Makefile.am
rename to trunk/milena/sandbox/green/doc/examples/stats/Makefile.am
diff --git a/trunk/milena/sandbox/green/stats/stats.cc b/trunk/milena/sandbox/green/doc/examples/stats/stats.cc
similarity index 100%
rename from trunk/milena/sandbox/green/stats/stats.cc
rename to trunk/milena/sandbox/green/doc/examples/stats/stats.cc
--
1.5.6.5
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-09-22 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix HSL values in test.
* tests/fun/v2v/hsl_to_rgb.cc: Fix HSL values.
---
hsl_to_rgb.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: trunk/milena/tests/fun/v2v/hsl_to_rgb.cc
===================================================================
--- trunk/milena/tests/fun/v2v/hsl_to_rgb.cc (revision 4515)
+++ trunk/milena/tests/fun/v2v/hsl_to_rgb.cc (revision 4516)
@@ -41,8 +41,8 @@
rgb8 ref[][2] = { { rgb8(0,0,0), rgb8(255,255,255) },
{ rgb8(128,128,128), rgb8(90,90, 90) } };
- hsl_f dat[][2] = { { hsl_f(0,0,0), hsl_f(0,0,255) },
- { hsl_f(0,0,128), hsl_f(0,0,90) } };
+ hsl_f dat[][2] = { { hsl_f(0,0,0), hsl_f(0,0,1.0) },
+ { hsl_f(0,0,128.0 / 255.0), hsl_f(0,0,90.0 / 255.0) } };
image2d<rgb8> ref_ima = make::image(ref);
image2d<hsl_f> ima = make::image(dat);
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-09-21 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add disk_ima test, improve HSL operations.
* fabien/igr/color/find_color.cc: Add operations on HSL values.
* fabien/mln/core/image/disk_ima.hh: Implement an image directly
mapped on disk.
* fabien/tests/core/image/Makefile: Add `disk_ima' target.
* fabien/tests/core/image/disk_ima.cc: New test file for the
disk_ima class.
---
igr/color/find_color.cc | 54 ++++++++++++++++++++++++++++++++++++++++++
mln/core/image/disk_ima.hh | 54 ++++++++++++++++++++++++++++++++++++++++++
tests/core/image/Makefile | 5 +++
tests/core/image/disk_ima.cc | 55 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 167 insertions(+), 1 deletion(-)
Index: trunk/milena/sandbox/fabien/igr/color/find_color.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/color/find_color.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/color/find_color.cc (revision 4515)
@@ -0,0 +1,54 @@
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/ppm/all.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/hsl.hh>
+
+#include <mln/convert/from_to.hh>
+#include <mln/data/convert.hh>
+
+using namespace mln;
+using value::rgb8;
+using value::hsl_;
+
+
+bool
+is_green(hsl_<float, float, float> value)
+{
+ if (value.hue() > 75 && value.hue() < 170 &&
+ value.sat() > 0.5 &&
+ value.lum() > 0.3 && value.lum() < 0.7)
+ return true;
+
+ return false;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ {
+ std::cout << "Usage: " << argv[0] << " input output" << std::endl;
+ return 1;
+ }
+
+ image2d<rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ typedef image2d<hsl_<float, float, float> > H;
+ H ima_hsl = data::convert(hsl_<float, float, float>(), input);
+ mln_piter_(H) p(ima_hsl.domain());
+ for_all(p)
+ {
+ if (!is_green(ima_hsl(p)))
+ {
+ ima_hsl(p).sat() = 0.3;
+ ima_hsl(p).lum() = 0.3;
+ }
+ }
+
+ image2d<rgb8> output = data::convert(rgb8(), ima_hsl);
+ io::ppm::save(output, argv[2]);
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/tests/core/image/disk_ima.cc
===================================================================
--- trunk/milena/sandbox/fabien/tests/core/image/disk_ima.cc (revision 0)
+++ trunk/milena/sandbox/fabien/tests/core/image/disk_ima.cc (revision 4515)
@@ -0,0 +1,55 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/disk_ima.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/literal/colors.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/debug/quiet.hh>
+
+
+using namespace mln;
+using value::rgb8;
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " input" << std::endl;
+ return 1;
+ }
+
+ //image2d<rgb8> ima;
+ disk_ima<rgb8> tiled_ima;
+
+ //io::ppm::load(ima, argv[1]);
+ io::ppm::load(tiled_ima, argv[1]);
+
+ //std::cout << "bbox: " << tiled_ima.bbox() << std::endl;
+ //std::cout << "file: " << tiled_ima.file_() << std::endl;
+
+ /*point2d pt0(0, 0);
+ mln_assertion(tiled_ima(pt0) == ima(pt0));
+
+ point2d pt(0, 1);
+ mln_assertion(tiled_ima(pt) == ima(pt));
+
+ point2d pt2(1, 0);
+ mln_assertion(tiled_ima(pt2) == ima(pt2));
+
+ point2d pt3(1, 1);
+ mln_assertion(tiled_ima(pt3) == ima(pt3));*/
+
+ mln_piter_(disk_ima<rgb8>) p(tiled_ima.domain());
+ for_all(p)
+ if (p.row() % 16 == 0)
+ {
+ //std::cout << tiled_ima(p);
+ tiled_ima(p) = literal::green;
+ //std::cout << " -> " << tiled_ima(p) << std::endl;
+ //mln_assertion(tiled_ima(p) == ima(p));
+ }
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/tests/core/image/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/tests/core/image/Makefile (revision 4514)
+++ trunk/milena/sandbox/fabien/tests/core/image/Makefile (revision 4515)
@@ -3,7 +3,10 @@
LIBS = `Magick++-config --cppflags --cxxflags --ldflags --libs`
INC = -I../../../ -I../../../../../
-all: tiled2d
+all: tiled2d disk_ima
tiled2d: tiled2d.cc
${CXX} ${CXXFLAGS} ${INC} $^ -o tiled2d
+
+disk_ima: disk_ima.cc
+ ${CXX} ${CXXFLAGS} ${INC} $^ -o disk_ima
Index: trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh (revision 0)
+++ trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh (revision 4515)
@@ -0,0 +1,643 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_CORE_IMAGE_DISK_IMA_HH
+# define MLN_CORE_IMAGE_DISK_IMA_HH
+
+/// \file
+/// Definition of the basic mln::disk_ima class.
+
+# include <mln/core/internal/image_primary.hh>
+# include <mln/core/internal/fixme.hh>
+# include <mln/core/alias/box2d.hh>
+# include <mln/core/routine/init.hh>
+
+# include <mln/border/thickness.hh>
+# include <mln/value/set.hh>
+# include <mln/fun/i2v/all_to.hh>
+# include <mln/value/proxy.hh>
+
+
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename T> struct disk_ima;
+
+
+ namespace internal
+ {
+
+ /// Data structure for \c mln::disk_ima<T>.
+ template <typename T>
+ struct data< disk_ima<T> >
+ {
+ data(const box2d& b, unsigned bdr);
+ ~data();
+
+ std::fstream* f_;
+ std::streampos pos_;
+ std::string file_;
+ bool loaded_;
+ T value_;
+
+ box2d b_; // theoretical box
+ unsigned bdr_;
+ box2d vb_; // virtual box, i.e., box including the virtual border
+
+ void update_vb_();
+ void allocate_();
+ void deallocate_();
+ void swap_(data< disk_ima<T> >& other_);
+ void reallocate_(unsigned new_border);
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct image_< disk_ima<T> > : default_image_< T, disk_ima<T> >
+ {
+ // misc
+ typedef trait::image::category::primary category;
+ typedef trait::image::speed::slow speed;
+ typedef trait::image::size::regular size;
+
+ // value
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
+ typedef trait::image::value_access::direct value_access;
+ typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_alignment::with_grid value_alignment;
+ typedef trait::image::value_io::read_only value_io;
+
+ // site / domain
+ typedef trait::image::pw_io::read_write pw_io;
+ typedef trait::image::localization::basic_grid localization;
+ typedef trait::image::dimension::two_d dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::extendable ext_domain;
+ typedef trait::image::ext_value::multiple ext_value;
+ typedef trait::image::ext_io::read_only ext_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ /// Basic 2D image class.
+ ///
+ /// The parameter \c T is the type of pixel values. This image class
+ /// stores data in memory and has a virtual border with constant
+ /// thickness around data.
+ ///
+ /// \ingroup modimageconcrete
+ //
+ template <typename T>
+ class disk_ima : public internal::image_primary< T, mln::box2d, disk_ima<T> >
+ {
+ typedef internal::image_primary< T, mln::box2d, disk_ima<T> > super_;
+ public:
+
+ /// Value associated type.
+ typedef T value;
+
+ /// Return type of read-only access.
+ typedef const T& rvalue;
+
+ /// Return type of read-write access.
+ typedef mln::value::proxy< disk_ima<T> > lvalue;
+
+
+ /// Skeleton.
+ typedef disk_ima< tag::value_<T> > skeleton;
+
+
+ /// Constructor without argument.
+ disk_ima();
+
+ /// Constructor with a box and the border thickness (default is
+ /// 3).
+ disk_ima(const box2d& b, unsigned bdr = border::thickness);
+
+
+ /// Initialize an empty image.
+ void init_(const box2d& b, unsigned bdr = border::thickness);
+
+ /// Initialize an empty image.
+ //void init_(const std::string& filename);
+
+
+ /// Test if \p p is valid.
+ bool has(const point2d& p) const;
+
+ /// Give the definition domain.
+ const box2d& domain() const;
+
+ /// Give the bounding box domain.
+ const box2d& bbox() const;
+
+ /// Read-only access to the image value located at point \p p.
+ const T& operator()(const point2d& p) const;
+
+ /// Read-write access to the image value located at point \p p.
+ mln::value::proxy< disk_ima<T> > operator()(const point2d& p);
+
+ // Read access to the image value located at point \p p.
+ const T& read_(const point2d& p) const;
+
+ // Write access to the image value located at point \p p.
+ void write_(const point2d& p, const T& value);
+
+
+ template <typename P>
+ T& alt(const P& p)
+ {
+ typedef def::coord coord_t;
+ mln_precondition(this->has(p));
+
+ return this->data_->array_ [*(coord_t*)(&p.p_hook_())] [*((coord_t*)(&p.p_hook_()) + 1)];
+ }
+
+
+ // Specific methods:
+ // -----------------
+
+ /// Read-only access to the image value located at (\p row, \p col).
+ const T& at_(unsigned row, unsigned col) const;
+
+ /// Read-write access to the image value located at (\p row, \p col).
+ T& at_(unsigned row, unsigned col);
+
+ /// Give the number of rows.
+ unsigned nrows() const;
+
+ /// Give the number of columns.
+ unsigned ncols() const;
+
+
+
+ /// Give the border thickness.
+ unsigned border() const;
+
+ /// Give the number of elements (points including border ones).
+ unsigned nelements() const;
+
+ /// Read-only access to the image value located at index \p i.
+ const T& element(unsigned i) const;
+
+ /// Read-write access to the image value located at index \p i.
+ T& element(unsigned i);
+
+ /// Give the delta-index corresponding to the delta-point \p dp.
+ int delta_index(const dpoint2d& dp) const;
+
+ /// Give the point corresponding to the index \p i.
+ point2d point_at_index(unsigned i) const;
+
+
+ // Hooks
+
+ /// Give a hook to the offset for accessing data.
+ const std::streampos& pos_() const;
+
+ /// Give a hook to the offset for accessing data.
+ std::streampos& pos_();
+
+ /// Give a hook to the filename.
+ const std::string& file_() const;
+
+ /// Give a hook to the filename.
+ std::string& file_();
+
+
+ /// Resize image border with new_border.
+ void resize_(unsigned new_border);
+ };
+
+
+
+ // Forward declaration
+
+ template <typename T>
+ void init_(tag::border_t, unsigned& bdr, const disk_ima<T>& model);
+
+ template <typename T, typename J>
+ void init_(tag::image_t, mln::disk_ima<T>& target, const J& model);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // init_
+
+ template <typename T>
+ inline
+ void init_(tag::border_t, unsigned& bdr, const disk_ima<T>& model)
+ {
+ bdr = model.border();
+ }
+
+ template <typename T, typename J>
+ inline
+ void init_(tag::image_t, disk_ima<T>& target, const J& model)
+ {
+ box2d b;
+ init_(tag::bbox, b, model);
+ unsigned bdr;
+ init_(tag::border, bdr, model);
+ target.init_(b, bdr);
+ }
+
+
+ // internal::data< disk_ima<T> >
+
+ namespace internal
+ {
+ template <typename T>
+ inline
+ data< disk_ima<T> >::data(const box2d& b, unsigned bdr)
+ : b_ (b),
+ bdr_ (bdr)
+ {
+ allocate_();
+ }
+
+ template <typename T>
+ inline
+ data< disk_ima<T> >::~data()
+ {
+ deallocate_();
+ }
+
+ template <typename T>
+ inline
+ void
+ data< disk_ima<T> >::update_vb_()
+ {
+ vb_.pmin() = b_.pmin() - dpoint2d(all_to(bdr_));
+ vb_.pmax() = b_.pmax() + dpoint2d(all_to(bdr_));
+ }
+
+ template <typename T>
+ inline
+ void
+ data< disk_ima<T> >::allocate_()
+ {
+ update_vb_();
+ mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_);
+ mln_postcondition(vb_.len(1) == b_.len(1) + 2 * bdr_);
+ }
+
+ template <typename T>
+ inline
+ void
+ data< disk_ima<T> >::deallocate_()
+ {
+ if (this->loaded_)
+ {
+ this->f_->close();
+ }
+ }
+
+ template <typename T>
+ inline
+ void
+ data< disk_ima<T> >::swap_(data< disk_ima<T> >& other_)
+ {
+ data< disk_ima<T> > self_ = *this;
+ *this = other_;
+ other_ = self_;
+ }
+
+ template <typename T>
+ inline
+ void
+ data< disk_ima<T> >::reallocate_(unsigned new_border)
+ {
+ data< disk_ima<T> >& tmp = *(new data< disk_ima<T> >(this->b_, new_border));
+ this->swap_(tmp);
+ }
+
+
+ } // end of namespace mln::internal
+
+
+ // disk_ima<T>
+
+ template <typename T>
+ inline
+ disk_ima<T>::disk_ima()
+ {
+ }
+
+ template <typename T>
+ inline
+ disk_ima<T>::disk_ima(const box2d& b, unsigned bdr)
+ {
+ init_(b, bdr);
+ }
+
+ template <typename T>
+ inline
+ void
+ disk_ima<T>::init_(const box2d& b, unsigned bdr)
+ {
+ mln_precondition(! this->is_valid());
+ this->data_ = new internal::data< disk_ima<T> >(b, bdr);
+ this->data_->loaded_ = false;
+ }
+
+ template <typename T>
+ inline
+ const box2d&
+ disk_ima<T>::domain() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->b_;
+ }
+
+ template <typename T>
+ inline
+ const box2d&
+ disk_ima<T>::bbox() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->b_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ disk_ima<T>::has(const point2d& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->vb_.has(p);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ disk_ima<T>::operator()(const point2d& p) const
+ {
+ return read_(p);
+ }
+
+ template <typename T>
+ inline
+ mln::value::proxy< disk_ima<T> >
+ disk_ima<T>::operator()(const point2d& p)
+ {
+ mln::value::proxy<disk_ima> prx(*this, p);
+ return prx;
+ }
+
+ template <typename T>
+ inline
+ const T&
+ disk_ima<T>::read_(const point2d& p) const
+ {
+ mln::disk_ima<T>* this_ = const_cast<mln::disk_ima<T>* >(this); // Trust me, I have to do this(_).
+ if (!this_->data_->loaded_)
+ {
+ this_->data_->f_ = new std::fstream(this->data_->file_.c_str());
+ this_->data_->loaded_ = true;
+ }
+ std::streampos offset = this_->data_->pos_;
+ offset += (this_->ncols() * p.row() + p.col()) * sizeof(T);
+ this_->data_->f_->seekg(offset);
+ this_->data_->f_->get((char*)(&this_->data_->value_), sizeof(T) + 1); // FIXME: I don't know why
+ // I have to add +1.
+ return this_->data_->value_;
+ }
+
+ template <typename T>
+ inline
+ void
+ disk_ima<T>::write_(const point2d& p, const T& value)
+ {
+ mln::disk_ima<T>* this_ = const_cast<mln::disk_ima<T>* >(this); // Trust me, I have to do this(_).
+ if (!this_->data_->loaded_)
+ {
+ this_->data_->f_ = new std::fstream(this->data_->file_.c_str());
+ this_->data_->loaded_ = true;
+ }
+ std::streampos offset = this_->data_->pos_;
+ offset += (this_->ncols() * p.row() + p.col()) * sizeof(T);
+ this_->data_->f_->seekg(offset);
+ this_->data_->f_->write((char*)(&value), sizeof(T) + 1); // FIXME: I don't know why
+ // I have to add +1.
+ }
+
+
+ // Specific methods:
+
+ template <typename T>
+ inline
+ const T&
+ disk_ima<T>::at_(unsigned row, unsigned col) const
+ {
+ mln_precondition(this->has(point2d(row, col)));
+ return this->data_->cache_(point2d(row, col));
+ }
+
+ template <typename T>
+ inline
+ T&
+ disk_ima<T>::at_(unsigned row, unsigned col)
+ {
+ mln_precondition(this->has(point2d(row, col)));
+ return this->data_->cache_(point2d(row, col));
+ }
+
+ template <typename T>
+ inline
+ unsigned
+ disk_ima<T>::nrows() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->b_.len(0);
+ }
+
+ template <typename T>
+ inline
+ unsigned
+ disk_ima<T>::ncols() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->b_.len(1);
+ }
+
+
+ // Hooks.
+
+ template <typename T>
+ inline
+ const std::streampos&
+ disk_ima<T>::pos_() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->pos_;
+ }
+
+ template <typename T>
+ inline
+ std::streampos&
+ disk_ima<T>::pos_()
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->pos_;
+ }
+
+ template <typename T>
+ inline
+ const std::string&
+ disk_ima<T>::file_() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->file_;
+ }
+
+ template <typename T>
+ inline
+ std::string&
+ disk_ima<T>::file_()
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->file_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/trait/pixter.hh>
+# include <mln/core/dpoints_pixter.hh>
+# include <mln/core/pixter2d.hh>
+// # include <mln/core/w_window.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ // pixter
+
+ template <typename T>
+ struct fwd_pixter< disk_ima<T> >
+ {
+ typedef fwd_pixter2d< disk_ima<T> > ret;
+ };
+
+ template <typename T>
+ struct fwd_pixter< const disk_ima<T> >
+ {
+ typedef fwd_pixter2d< const disk_ima<T> > ret;
+ };
+
+ template <typename T>
+ struct bkd_pixter< disk_ima<T> >
+ {
+ typedef bkd_pixter2d< disk_ima<T> > ret;
+ };
+
+ template <typename T>
+ struct bkd_pixter< const disk_ima<T> >
+ {
+ typedef bkd_pixter2d< const disk_ima<T> > ret;
+ };
+
+ // qixter
+
+ template <typename T, typename W>
+ struct fwd_qixter< disk_ima<T>, W >
+ {
+ typedef dpoints_fwd_pixter< disk_ima<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct fwd_qixter< const disk_ima<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const disk_ima<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< disk_ima<T>, W >
+ {
+ typedef dpoints_bkd_pixter< disk_ima<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< const disk_ima<T>, W >
+ {
+ typedef dpoints_bkd_pixter< const disk_ima<T> > ret;
+ };
+
+ // nixter
+
+ template <typename T, typename N>
+ struct fwd_nixter< disk_ima<T>, N >
+ {
+ typedef dpoints_fwd_pixter< disk_ima<T> > ret;
+ };
+
+ template <typename T, typename N>
+ struct fwd_nixter< const disk_ima<T>, N >
+ {
+ typedef dpoints_fwd_pixter< const disk_ima<T> > ret;
+ };
+
+ template <typename T, typename N>
+ struct bkd_nixter< disk_ima<T>, N >
+ {
+ typedef dpoints_bkd_pixter< disk_ima<T> > ret;
+ };
+
+ template <typename T, typename N>
+ struct bkd_nixter< const disk_ima<T>, N >
+ {
+ typedef dpoints_bkd_pixter< const disk_ima<T> > ret;
+ };
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+# include <mln/make/image.hh>
+
+
+#endif // ! MLN_CORE_IMAGE_DISK_IMA_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-09-21 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add new algorithm for conversion HSL to RGB.
* mln/fun/v2v/hsl_to_rgb.hh: Add new algorithm for conversion.
* mln/value/rgb.hh: Enable convertion to HSL.
---
fun/v2v/hsl_to_rgb.hh | 87 +++++++++++++++++++++++++++++++++++---------------
value/rgb.hh | 50 ++++++++++++++--------------
2 files changed, 86 insertions(+), 51 deletions(-)
Index: trunk/milena/mln/value/rgb.hh
===================================================================
--- trunk/milena/mln/value/rgb.hh (revision 4513)
+++ trunk/milena/mln/value/rgb.hh (revision 4514)
@@ -29,7 +29,7 @@
# include <mln/value/ops.hh>
-// # include <mln/fun/v2v/hsl_to_rgb.hh>
+# include <mln/fun/v2v/hsl_to_rgb.hh>
# include <mln/value/concept/vectorial.hh>
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
@@ -42,24 +42,24 @@
-// namespace fun
-// {
+ namespace fun
+ {
-// namespace v2v
-// {
+ namespace v2v
+ {
-// template <typename T_rgb>
-// struct f_hsl_to_rgb_;
+ template <typename T_rgb>
+ struct f_hsl_to_rgb_;
-// typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
+ typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
-// extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
+ extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
-// }
+ }
-// }
+ }
namespace literal
@@ -90,11 +90,11 @@
}
-// // Forward declaration.
-// namespace value
-// {
-// template <typename H, typename S, typename L> class hsl_;
-// }
+ // Forward declaration.
+ namespace value
+ {
+ template <typename H, typename S, typename L> class hsl_;
+ }
namespace convert
@@ -115,9 +115,9 @@
template <unsigned m>
void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-// // hsl -> rgb8.
-// template <typename H, typename S, typename L>
-// void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
+ // hsl -> rgb8.
+ template <typename H, typename S, typename L>
+ void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
// // hsl -> rgb16.
// template <typename H, typename S, typename L>
@@ -791,12 +791,12 @@
to = value::rgb<m>(from, from, from);
}
-// template <typename H, typename S, typename L>
-// void
-// from_to_(const value::hsl_<H,S,L>& from, value::rgb<8>& to)
-// {
-// to = fun::v2v::f_hsl_to_rgb_3x8(from);
-// }
+ template <typename H, typename S, typename L>
+ void
+ from_to_(const value::hsl_<H,S,L>& from, value::rgb<8>& to)
+ {
+ to = fun::v2v::f_hsl_to_rgb_3x8(from);
+ }
// template <typename H, typename S, typename L>
// void
Index: trunk/milena/mln/fun/v2v/hsl_to_rgb.hh
===================================================================
--- trunk/milena/mln/fun/v2v/hsl_to_rgb.hh (revision 4513)
+++ trunk/milena/mln/fun/v2v/hsl_to_rgb.hh (revision 4514)
@@ -92,40 +92,75 @@
/// \}
+ // This method implement the conversion from HSL to RGB
+ // explained by Wikipedia.
+ // url: http://en.wikipedia.org/wiki/HSL_and_HSV
template <typename T_rgb>
template <typename T_hsl>
inline
T_rgb
f_hsl_to_rgb_<T_rgb>::operator()(const T_hsl& hsl) const
{
- typedef typename T_rgb::red_t red_t;
- typedef typename T_rgb::green_t green_t;
- typedef typename T_rgb::blue_t blue_t;
-
- static math::round<red_t> to_r;
- static math::round<green_t> to_g;
- static math::round<blue_t> to_b;
-
- static const float
- sqrt3_3 = std::sqrt(3.0f) / 3.0f,
- inv_sqrt6 = 1 / std::sqrt(6.0f),
- inv_sqrt2 = 1 / std::sqrt(2.0f);
-
- float
- h = hsl.hue() / 180.0 * 3.1415,
- alpha = hsl.sat() * std::cos(h),
- beta = hsl.sat() * std::sin(h);
-
-
- red_t r = to_r(sqrt3_3 * hsl.lum() + 2 * inv_sqrt6 * beta);
- green_t g =
- to_g(sqrt3_3 * hsl.lum() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
- blue_t b =
- to_b(sqrt3_3 * hsl.lum() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ const float q = (hsl.lum() < 0.5) ? hsl.lum() * (1.0 + hsl.sat()) :
+ hsl.lum() + hsl.sat() - (hsl.lum() * hsl.sat());
+ const float p = 2.0 * hsl.lum() - q;
+ const float hk = hsl.hue() / 360.0; // hk = normalized hue
+ float tr = hk + (1.0 / 3.0);
+ float tg = hk;
+ float tb = hk - (1.0 / 3.0);
+
+ if (tr < 0.0)
+ tr += 1.0;
+ if (tr > 1.0)
+ tr -= 1.0;
+
+ if (tg < 0.0)
+ tg += 1.0;
+ if (tg > 1.0)
+ tg -= 1.0;
+
+ if (tb < 0.0)
+ tb += 1.0;
+ if (tb > 1.0)
+ tb -= 1.0;
+
+ // Red.
+ float red;
+ if (tr < (1.0 / 6.0))
+ red = p + ((q - p) * 6 * tr);
+ else if (tr < (1.0 / 2.0))
+ red = q;
+ else if (tr < (2.0 / 3.0))
+ red = p + ((q - p) * 6 * ((2.0 / 3.0) - tr));
+ else
+ red = p;
+
+ // Green.
+ float green;
+ if (tg < (1.0 / 6.0))
+ green = p + ((q - p) * 6 * tg);
+ else if (tg < (1.0 / 2.0))
+ green = q;
+ else if (tg < (2.0 / 3.0))
+ green = p + ((q - p) * 6 * ((2.0 / 3.0) - tg));
+ else
+ green = p;
+
+ // Blue.
+ float blue;
+ if (tb < (1.0 / 6.0))
+ blue = p + ((q - p) * 6 * tb);
+ else if (tb < (1.0 / 2.0))
+ blue = q;
+ else if (tb < (2.0 / 3.0))
+ blue = p + ((q - p) * 6 * ((2.0 / 3.0) - tb));
+ else
+ blue = p;
- T_rgb rgb(r, g, b);
+ // Each component is in [0, 1].
+ T_rgb rgb_result(red * 255, green * 255, blue * 255);
- return rgb;
+ return rgb_result;
}
# endif // !MLN_INCLUDE_ONLY
1
0
21 Sep '09
* apps/graph-morpho/asf-image2d.cc: New.
* apps/graph-morpho/Makefile.am
(noinst_PROGRAMS): Add asf-image2d.
(asf_image2d_SOURCES): New.
(TESTS): Remove asf-complex1d.
---
milena/ChangeLog | 10 +++++
milena/apps/graph-morpho/Makefile.am | 5 ++-
milena/apps/graph-morpho/asf-image2d.cc | 57 +++++++++++++++++++++++++++++++
3 files changed, 70 insertions(+), 2 deletions(-)
create mode 100644 milena/apps/graph-morpho/asf-image2d.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 64302c1..4b18664 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2009-09-21 Roland Levillain <roland(a)lrde.epita.fr>
+ New application: apps/graph-morpho/asf-image2d.
+
+ * apps/graph-morpho/asf-image2d.cc: New.
+ * apps/graph-morpho/Makefile.am
+ (noinst_PROGRAMS): Add asf-image2d.
+ (asf_image2d_SOURCES): New.
+ (TESTS): Remove asf-complex1d.
+
+2009-09-21 Roland Levillain <roland(a)lrde.epita.fr>
+
New application: apps/graph-morpho/samples-image2d.
* apps/graph-morpho/samples-image2d.cc: New.
diff --git a/milena/apps/graph-morpho/Makefile.am b/milena/apps/graph-morpho/Makefile.am
index 3c2ee26..70e177e 100644
--- a/milena/apps/graph-morpho/Makefile.am
+++ b/milena/apps/graph-morpho/Makefile.am
@@ -22,12 +22,13 @@ AM_CXXFLAGS = $(APPS_CXXFLAGS)
noinst_HEADERS = io.hh morpho.hh make_complex2d.hh
-noinst_PROGRAMS = samples-complex1d samples-image2d asf-complex1d
+noinst_PROGRAMS = samples-complex1d samples-image2d asf-complex1d asf-image2d
samples_complex1d_SOURCES = samples-complex1d.cc
samples_image2d_SOURCES = samples-image2d.cc
asf_complex1d_SOURCES = asf-complex1d.cc
+asf_image2d_SOURCES = asf-image2d.cc
-TESTS = samples-complex1d asf-complex1d samples-image2d
+TESTS = samples-complex1d samples-image2d
# Graph images stored in 2D PBM files.
EXTRA_DIST = x.pbm y.pbm z.pbm
diff --git a/milena/apps/graph-morpho/asf-image2d.cc b/milena/apps/graph-morpho/asf-image2d.cc
new file mode 100644
index 0000000..395d20d
--- /dev/null
+++ b/milena/apps/graph-morpho/asf-image2d.cc
@@ -0,0 +1,57 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+/// \file
+/// \brief Alternate Sequential Filters in graph space implemented on
+/// mln::image2d-based cubical complexes.
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include "apps/graph-morpho/morpho.hh"
+
+#include "apps/graph-morpho/make_complex2d.hh"
+#include "apps/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ // Remove borders so as to avoid side effects.
+ border::thickness = 0;
+
+ // Input image.
+ image2d<bool> input =
+ io::pbm::load(MLN_APPS_DIR "/graph-morpho/zebra-noisy.pbm");
+
+ // Create an binary 2d image representing a 4-connexity graph image
+ // (actually, a cubical 2-complex) by doubling the resolution of the
+ // input image to insert edges (and squares) between pixels.
+ image2d<bool> input_x2 = make_complex2d(input);
+
+ // ASF.
+ io::pbm::save(unmake_complex2d(asf(input_x2, 2)), "asf_ima_2.pbm");
+}
--
1.6.4.2
1
0