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
* demo/src/mainwindow.cc: Do not always resize pics.
* filter/object_groups_small.hh: Add missing traces.
* preprocessing/split_bg_fg.hh: Fix type ambiguities.
* src/table/extract.cc,
* src/text/grouping/group_from_double_link_filter_non_aligned.cc,
* src/text/grouping/group_from_rag.cc: Cosmetic changes.
---
scribo/ChangeLog | 14 ++++++++++++++
scribo/demo/src/mainwindow.cc | 3 ++-
scribo/filter/object_groups_small.hh | 3 +++
scribo/preprocessing/split_bg_fg.hh | 9 ++++++---
scribo/src/table/extract.cc | 6 ++++--
.../group_from_double_link_filter_non_aligned.cc | 2 +-
scribo/src/text/grouping/group_from_rag.cc | 4 ++--
7 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 47627e0..0a7f625 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,17 @@
+2009-09-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes in Scribo.
+
+ * demo/src/mainwindow.cc: Do not always resize pics.
+
+ * filter/object_groups_small.hh: Add missing traces.
+
+ * preprocessing/split_bg_fg.hh: Fix type ambiguities.
+
+ * src/table/extract.cc,
+ * src/text/grouping/group_from_double_link_filter_non_aligned.cc,
+ * src/text/grouping/group_from_rag.cc: Cosmetic changes.
+
2009-09-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Small fixes in Scribo.
diff --git a/scribo/demo/src/mainwindow.cc b/scribo/demo/src/mainwindow.cc
index f808d8b..4a12359 100644
--- a/scribo/demo/src/mainwindow.cc
+++ b/scribo/demo/src/mainwindow.cc
@@ -310,7 +310,8 @@ namespace scribo
item = view->scene()->addPixmap(pixmap);
view->scene()->setSceneRect(item->boundingRect());
Q_ASSERT(item != 0);
- view->fitInView(item->boundingRect(), Qt::KeepAspectRatio);
+ if (pixmap.width() > view->maximumViewportSize().width())
+ view->fitInView(item->boundingRect(), Qt::KeepAspectRatio);
view_to_item(view) = item;
bool b = (mainResultItem_ != 0 || mainRefItem_ != 0);
diff --git a/scribo/filter/object_groups_small.hh b/scribo/filter/object_groups_small.hh
index 1e6c636..6a50aba 100644
--- a/scribo/filter/object_groups_small.hh
+++ b/scribo/filter/object_groups_small.hh
@@ -68,6 +68,8 @@ namespace scribo
object_groups_small(const object_groups<L>& groups,
unsigned n_links)
{
+ trace::entering("scribo::filter::object_groups_small");
+
mln_precondition(groups.is_valid());
// Counting the number of objects per group.
@@ -81,6 +83,7 @@ namespace scribo
if (group_size[groups[i]] < n_links)
output(i) = 0;
+ trace::exiting("scribo::filter::object_groups_small");
return output;
}
diff --git a/scribo/preprocessing/split_bg_fg.hh b/scribo/preprocessing/split_bg_fg.hh
index 7e05d0d..f64635b 100644
--- a/scribo/preprocessing/split_bg_fg.hh
+++ b/scribo/preprocessing/split_bg_fg.hh
@@ -31,6 +31,7 @@
///
/// Split the background and the foreground.
+# include <mln/core/macros.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/routine/duplicate.hh>
@@ -61,6 +62,8 @@
# include <mln/labeling/compute.hh>
# include <mln/accu/stat/mean.hh>
+# include <mln/util/couple.hh>
+
@@ -84,7 +87,7 @@ namespace scribo
and the second is the foreground.
*/
template <typename I>
- util::couple<mln_concrete(I), mln_concrete(I)>
+ mln::util::couple<mln_concrete(I), mln_concrete(I)>
split_bg_fg(const Image<I>& input_, unsigned lambda, unsigned delta);
@@ -287,7 +290,7 @@ namespace scribo
// }
typedef accu::stat::mean< rgb8, algebra::vec<3,float>, rgb8 > A;
- util::array<rgb8> m = labeling::compute(A(), input, con, nblobs);
+ mln::util::array<rgb8> m = labeling::compute(A(), input, con, nblobs);
data::fill((output | pw::value(mask)).rw(),
data::transform(lab, m));
@@ -305,7 +308,7 @@ namespace scribo
// Facade
template <typename I>
- util::couple<mln_concrete(I), mln_concrete(I)>
+ mln::util::couple<mln_concrete(I), mln_concrete(I)>
split_bg_fg(const Image<I>& input_, unsigned lambda, unsigned delta)
{
trace::entering("scribo::preprocessing::split_bg_fg");
diff --git a/scribo/src/table/extract.cc b/scribo/src/table/extract.cc
index 060f2f8..c510753 100644
--- a/scribo/src/table/extract.cc
+++ b/scribo/src/table/extract.cc
@@ -65,9 +65,11 @@ the background, other colors indicates cells.");
io::pbm::load(input, argv[1]);
value::label_16 ncells;
- image2d<value::label_16> tables = scribo::table::extract(input, ncells).first();
+ image2d<value::label_16>
+ tables = scribo::table::extract(input, ncells).first();
- io::ppm::save(mln::labeling::colorize(value::rgb8(), tables, ncells), argv[3]);
+ io::ppm::save(mln::labeling::colorize(value::rgb8(), tables, ncells),
+ argv[3]);
io::dump::save(tables, argv[2]);
diff --git a/scribo/src/text/grouping/group_from_double_link_filter_non_aligned.cc b/scribo/src/text/grouping/group_from_double_link_filter_non_aligned.cc
index fce389e..ef9362d 100644
--- a/scribo/src/text/grouping/group_from_double_link_filter_non_aligned.cc
+++ b/scribo/src/text/grouping/group_from_double_link_filter_non_aligned.cc
@@ -141,7 +141,7 @@ int main(int argc, char *argv[])
// Filter non-correctly aligned grouped objects.
object_links<L> filtered_links
- = filter::object_links_non_h_aligned(text, double_link, atoi(argv[4]));
+ = filter::object_links_non_h_aligned(text, double_link, atof(argv[4]));
text_t aligned_grouped_text
diff --git a/scribo/src/text/grouping/group_from_rag.cc b/scribo/src/text/grouping/group_from_rag.cc
index 8b3d5fd..e354d09 100644
--- a/scribo/src/text/grouping/group_from_rag.cc
+++ b/scribo/src/text/grouping/group_from_rag.cc
@@ -127,8 +127,8 @@ namespace scribo
bool operator()(const point2d& p1, const point2d& p2) const
{
- return (math::sqrt(math::sqr(p1.row() - p2.row())
- + math::sqr(p1.col() - p2.col()))) < 5;
+ return (math::sqrt(math::sqr(static_cast<float>(p1.row() - p2.row()))
+ + math::sqr(static_cast<float>(p1.col() - p2.col())))) < 5;
}
};
--
1.5.6.5
1
0
* doc/examples/Makefile.am: Fix invalid source filename.
* mln/fun/from_accu.hh: Fix guard.
* mln/linear/gaussian_directional_2d.hh: Fix a warning.
* tests/accu/pair.cc: revamp header.
---
milena/ChangeLog | 14 ++++-
milena/doc/examples/Makefile.am | 4 +-
milena/mln/fun/from_accu.hh | 83 ++++++++++++++++++++++----
milena/mln/linear/gaussian_directional_2d.hh | 2 +-
milena/tests/accu/pair.cc | 5 +-
5 files changed, 91 insertions(+), 17 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e205a6c..1881b78 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2009-09-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes.
+
+ * doc/examples/Makefile.am: Fix invalid source filename.
+
+ * mln/fun/from_accu.hh: Fix guard.
+
+ * mln/linear/gaussian_directional_2d.hh: Fix a warning.
+
+ * tests/accu/pair.cc: revamp header.
+
2009-09-24 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add correct reference for HSL to RGB conversion.
@@ -324,7 +336,7 @@
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).
diff --git a/milena/doc/examples/Makefile.am b/milena/doc/examples/Makefile.am
index 843c6b3..e6c3cd6 100644
--- a/milena/doc/examples/Makefile.am
+++ b/milena/doc/examples/Makefile.am
@@ -33,7 +33,7 @@ EXTRA_PROGRAMS = \
fill-part-image \
fill-subdomain \
fill-subdomain-shorter \
- fill-subimage-cfun \
+ fill-imageif-cfun \
first_routine \
forall-piter \
fun-p2v-1 \
@@ -94,7 +94,7 @@ fill_call_1_SOURCES = fill-call-1.cc
fill_part_image_SOURCES = fill-part-image.cc
fill_subdomain_SOURCES = fill-subdomain.cc
fill_subdomain_shorter_SOURCES = fill-subdomain-shorter.cc
-fill_subimage_cfun_SOURCES = fill-subimage-cfun.cc
+fill_imageif_cfun_SOURCES = fill-imageif-cfun.cc
first_routine_SOURCES = tuto3/first_routine.cc
forall_piter_SOURCES = forall-piter.cc
fun_p2v_1_SOURCES = fun-p2v-1.cc
diff --git a/milena/mln/fun/from_accu.hh b/milena/mln/fun/from_accu.hh
index 9228a30..f01a93d 100644
--- a/milena/mln/fun/from_accu.hh
+++ b/milena/mln/fun/from_accu.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,24 +24,32 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+/// \file
+///
+/// Wrap an accumulator into a function.
+
+
#ifndef MLN_FUN_FROM_ACCU_HH
# define MLN_FUN_FROM_ACCU_HH
# include <mln/fun/unary_param.hh>
# include <mln/core/concept/accumulator.hh>
+
namespace mln
{
- // from_accu: wrap an accumulator into a function
namespace fun
{
+
+ /*! \brief Wrap an accumulator into a function.
+ */
template <typename A>
struct from_accu : unary_param<from_accu<A>, A*>
{
- from_accu() : unary_param<from_accu<A>, A*>() {};
- from_accu(A* a) : unary_param<from_accu<A>, A*>(a) {};
+ from_accu();
+ from_accu(A* a);
};
} // end of namespace mln::fun
@@ -58,20 +67,70 @@ namespace mln
typedef typename A::argument argument;
typedef A* param_t;
- static inline
- result read(const param_t& accu_, const argument& x)
- {
- mln_precondition(accu_ != 0);
+ static result read(const param_t& accu_, const argument& x);
- accu_->take(x);
- return accu_->to_result ();
- }
};
} // end of namespace mln::trait::next
} // end of namespace mln::trait
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace fun
+ {
+
+ template <typename A>
+ inline
+ from_accu<A>::from_accu()
+ : unary_param<from_accu<A>, A*>()
+ {
+
+ }
+
+
+ template <typename A>
+ inline
+ from_accu<A>::from_accu(A* a)
+ : unary_param<from_accu<A>, A*>(a)
+ {
+
+ }
+
+ } // end of namespace mln::fun
+
+
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename A, typename T>
+ inline
+ typename set_unary_<mln::fun::from_accu<A>, mln::Object, T>::result
+ set_unary_<mln::fun::from_accu<A>,
+ mln::Object, T>::read(const param_t& accu_,
+ const argument& x)
+ {
+ mln_precondition(accu_ != 0);
+
+ accu_->take(x);
+ return accu_->to_result ();
+ }
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln
-#endif /* ! MLN_FUN_FROM_ACCU_HH */
+#endif // ! MLN_FUN_FROM_ACCU_HH
diff --git a/milena/mln/linear/gaussian_directional_2d.hh b/milena/mln/linear/gaussian_directional_2d.hh
index 37a8449..bda0eda 100644
--- a/milena/mln/linear/gaussian_directional_2d.hh
+++ b/milena/mln/linear/gaussian_directional_2d.hh
@@ -453,7 +453,7 @@ namespace mln
o_current = o_start;
for (int i = 0; i < len; ++i)
{
- ima.element(o_current) = (tmp1[i] + tmp2[i]);
+ ima.element(o_current) = static_cast<mln_value(I)>(tmp1[i] + tmp2[i]);
o_current += delta_offset;
}
}
diff --git a/milena/tests/accu/pair.cc b/milena/tests/accu/pair.cc
index 83667da..de03b7d 100644
--- a/milena/tests/accu/pair.cc
+++ b/milena/tests/accu/pair.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,6 +24,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+/// \file
+
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
--
1.5.6.5
1
0
24 Sep '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-09-24 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add correct reference for HSL to RGB conversion.
* mln/fun/v2v/hsl_to_rgb.hh: Add correct reference for HSL
to RGB conversion.
---
hsl_to_rgb.hh | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
Index: trunk/milena/mln/fun/v2v/hsl_to_rgb.hh
===================================================================
--- trunk/milena/mln/fun/v2v/hsl_to_rgb.hh (revision 4545)
+++ trunk/milena/mln/fun/v2v/hsl_to_rgb.hh (revision 4546)
@@ -92,15 +92,23 @@
/// \}
- // This method implement the conversion from HSL to RGB
- // explained by Wikipedia.
- // url: http://en.wikipedia.org/wiki/HSL_and_HSV
+ /// This method implements the conversion from HSL to RGB as described by
+ /// Max K. Agoston in `Computer Graphics and Geometric Modeling:
+ /// Implementation and Algorithms (2005)'.
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;
+
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;
@@ -158,7 +166,11 @@
blue = p;
// Each component is in [0, 1].
- T_rgb rgb_result(red * 255, green * 255, blue * 255);
+ red_t r = to_r(red * 255);
+ green_t g = to_g(green * 255);
+ blue_t b = to_b(blue * 255);
+
+ T_rgb rgb_result(r, g, b);
return rgb_result;
}
1
0
24 Sep '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-09-24 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add benchmark for disk-mapped image and work for color types.
* fabien/igr/color/find_color.cc: Find green color in an image.
* fabien/mln/core/image/disk_ima.hh: Implement disk-mapped image.
* fabien/mln/io/pnm/load_disk_ima.hh: Implement loading of disk-
mapped image from a PNM file.
* fabien/tests/core/image/bench.sh: New script for benchmarking
disk-mapped image and tiled image.
* fabien/mln/test/conversion.hh: Implement test for evaluation of
type conversion.
* fabien/tests/test/conversion.cc: Test evalution of type conversion.
---
igr/color/find_color.cc | 34 ++++++++---
mln/core/image/disk_ima.hh | 1
mln/io/pnm/load_disk_ima.hh | 88 ++++++++++++++++++++++++++++
mln/test/conversion.hh | 136 ++++++++++++++++++++++++++++++++++++++++++++
tests/core/image/bench.sh | 12 +++
tests/test/conversion.cc | 33 ++++++++++
6 files changed, 297 insertions(+), 7 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/color/find_color.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/color/find_color.cc (revision 4544)
+++ trunk/milena/sandbox/fabien/igr/color/find_color.cc (revision 4545)
@@ -1,18 +1,23 @@
#include <mln/core/image/image2d.hh>
+#include <mln/io/pgm/all.hh>
#include <mln/io/ppm/all.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/hsl.hh>
+#include <mln/value/int_u8.hh>
#include <mln/convert/from_to.hh>
#include <mln/data/convert.hh>
+#include <mln/math/diff_abs.hh>
using namespace mln;
using value::rgb8;
using value::hsl_;
+using value::int_u8;
+inline
bool
is_green(hsl_<float, float, float> value)
{
@@ -24,6 +29,24 @@
return false;
}
+inline
+int_u8
+how_green(hsl_<float, float, float> value)
+{
+ float proba = 0.0;
+
+ if (value.hue() > 60 && value.hue() < 180)
+ {
+ proba += 1.f - ((math::diff_abs(120.f, value.hue()) / 100.0) / 0.6);
+ proba *= value.sat();
+ proba *= 1.f - (math::diff_abs(0.5f, value.lum()));
+ }
+
+ if (proba > 1.f)
+ proba = 1.f;
+ return (int_u8) (proba * 255);
+}
+
int main(int argc, char* argv[])
{
if (argc != 3)
@@ -34,21 +57,18 @@
image2d<rgb8> input;
io::ppm::load(input, argv[1]);
+ image2d<int_u8> output;
+ initialize(output, input);
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;
- }
+ output(p) = how_green(ima_hsl(p));
}
- image2d<rgb8> output = data::convert(rgb8(), ima_hsl);
- io::ppm::save(output, argv[2]);
+ io::pgm::save(output, argv[2]);
return 0;
}
Index: trunk/milena/sandbox/fabien/tests/test/conversion.cc
===================================================================
--- trunk/milena/sandbox/fabien/tests/test/conversion.cc (revision 0)
+++ trunk/milena/sandbox/fabien/tests/test/conversion.cc (revision 4545)
@@ -0,0 +1,33 @@
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/pgm/all.hh>
+#include <mln/io/ppm/all.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/hsl.hh>
+
+#include <mln/test/conversion.hh>
+
+using namespace mln;
+using value::rgb8;
+using value::hsl_;
+using value::int_u8;
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " input" << std::endl;
+ return 1;
+ }
+
+ image2d<rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ float delta = test::conversion(input, hsl_<float, float, float>());
+
+ std::cout << "delta conversion = " << delta << std::endl;
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/tests/core/image/bench.sh
===================================================================
--- trunk/milena/sandbox/fabien/tests/core/image/bench.sh (revision 0)
+++ trunk/milena/sandbox/fabien/tests/core/image/bench.sh (revision 4545)
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+make disk_ima
+make tiled2d
+
+echo "---"
+echo "Disk Image Performance"
+time ./disk_ima $1
+
+echo "---"
+echo "Tiled Image Performance"
+time ./tiled2d $1
Property changes on: trunk/milena/sandbox/fabien/tests/core/image/bench.sh
___________________________________________________________________
Added: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/mln/test/conversion.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/test/conversion.hh (revision 0)
+++ trunk/milena/sandbox/fabien/mln/test/conversion.hh (revision 4545)
@@ -0,0 +1,136 @@
+// 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_TEST_CONVERSION_HH
+# define MLN_TEST_CONVERSION_HH
+
+/// \file
+///
+/// Test a conversion on the pixel values of an image.
+
+# include <mln/core/concept/image.hh>
+# include <mln/data/convert.hh>
+# include <mln/math/diff_abs.hh>
+# include <mln/value/rgb8.hh>
+
+
+namespace mln
+{
+
+ namespace test
+ {
+
+ /// Test if all pixel values of \p ima can correctly convert into
+ /// the type of \p value and then reconvert into their original
+ /// type.
+ ///
+ /// \param[in] ima The image.
+ /// \param[in] value A value of the conversion type.
+ //
+ template <typename I, typename V>
+ float conversion(const Image<I>& ima, const V& value);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ template <typename V>
+ inline
+ float color_distance(const V& color1, const V& color2)
+ {
+ return -1.0; // FIXME
+ }
+
+ template <>
+ inline
+ float color_distance<value::rgb8>(const value::rgb8& color1, const value::rgb8& color2)
+ {
+ float dist = 0.0;
+
+ dist += math::diff_abs(color1.red(), color2.red());
+ dist += math::diff_abs(color1.green(), color2.green());
+ dist += math::diff_abs(color1.blue(), color2.blue());
+
+ dist /= 3 * 255;
+
+ return dist;
+ }
+
+ /// \return The percentage of points which value is not preserved.
+ /// The return value is normalized ([0..1]).
+ template <typename I, typename V>
+ inline
+ float conversion_(const I& ima, const V& value)
+ {
+ float delta = 0;
+
+ typedef mln_ch_value(I, V) J;
+ J converted = data::convert(value, ima);
+ I output = data::convert(mln_value(I)(), converted);
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ delta += color_distance(ima(p), output(p));
+ //if (ima(p) != output(p))
+ // delta += 1.0;
+ }
+
+ delta /= ima.nelements();
+ return delta;
+ }
+
+ } // end of namespace mln::test::impl
+
+
+
+ // Facades.
+
+
+ template <typename I, typename V>
+ inline
+ float conversion(const Image<I>& ima, const V& value)
+ {
+ trace::entering("test::conversion");
+
+ float res = impl::conversion_(exact(ima), value);
+
+ trace::exiting("test::conversion");
+ return res;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::test
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TEST_CONVERSION_HH
Index: trunk/milena/sandbox/fabien/mln/io/pnm/load_disk_ima.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/io/pnm/load_disk_ima.hh (revision 0)
+++ trunk/milena/sandbox/fabien/mln/io/pnm/load_disk_ima.hh (revision 4545)
@@ -0,0 +1,88 @@
+// 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_PNM_LOAD_DISK_IMA_HH
+# define MLN_IO_PNM_LOAD_DISK_IMA_HH
+
+/// \file
+///
+/// Define a function which loads an image of kind PNM 8/16bits with
+/// given path.
+
+# include <iostream>
+# include <fstream>
+# include <string>
+
+# include <mln/io/pnm/load_header.hh>
+# include <mln/io/pnm/max_component.hh>
+# include <mln/io/pnm/macros.hh>
+
+# include <mln/metal/is_a.hh>
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace pnm
+ {
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Warning if we try to load uncontiguous 2D PNM file into a disk
+ // image, this is not currently supported.
+ template <typename V>
+ inline
+ void load_raw_2d_uncontiguous(std::ifstream& file, disk_ima<V>& ima)
+ {
+ (void) file;
+ (void) ima;
+ std::cout << "You can't load an uncontiguous 2D PNM file into ";
+ std::cout << "a disk image" << std::endl;
+ abort();
+ }
+
+ // Load raw 2d for disk images.
+ template <typename T>
+ inline
+ void load_raw_2d_contiguous(std::ifstream& file, disk_ima<T>& ima, const std::string& filename)
+ {
+ ima.pos_() = file.tellg();
+ ima.file_() = filename;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::pnm
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_PNM_LOAD_DISK_IMA_HH
Index: trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh
===================================================================
--- trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh (revision 4544)
+++ trunk/milena/sandbox/fabien/mln/core/image/disk_ima.hh (revision 4545)
@@ -638,6 +638,7 @@
# include <mln/make/image.hh>
+# include <mln/io/pnm/load_disk_ima.hh>
#endif // ! MLN_CORE_IMAGE_DISK_IMA_HH
1
0
Rename fraction directory into frac directory.
* green/doc/examples/fraction/frac.cc : Delete.
* green/doc/examples/fraction/frac.hh : Delete.
* green/doc/examples/fraction/gcd.hh : Delete
* green/doc/examples/fraction/sign_prod.hh : Delete.
* green/doc/examples/frac/frac.cc : New.
* green/doc/examples/frac/frac.hh : New.
* green/doc/examples/frac/gcd.hh : New.
* green/doc/examples/frac/sign_prod.hh : New.
* green/doc/examples/frac/Makefile.am : New.
Collect some tmp results.
* green/mln/io/plot/save_histo_sh.hh
(save_histo_sh<2d>) : Comment method.
* green/mln/mln/accu/stat/histo1d.hh
: Update documentation.
* green/mln/mln/accu/stat/histo3d_rgb.hh
: Update documentation.
* green/mln/mln/accu/stat/histo3d_hsl.hh
: Update documentation.
* green/mln/tests/accu/stat/histo1d/histo1d.cc
(test_8bits_integration, main) : Comment unused code, save tmp results.
(test_8bits_operator_equal) : Test infer "!=" operator.
* green/mln/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
(test_integration, main) : Comment unused code, save tmp results.
* green/mln/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
(test_integration, main) : Comment unused code, save tmp results.
---
trunk/milena/sandbox/ChangeLog | 35 +++++
.../sandbox/green/doc/examples/frac/Makefile.am | 148 ++++++++++++++++++++
.../green/doc/examples/{fraction => frac}/frac.cc | 0
.../green/doc/examples/{fraction => frac}/frac.hh | 0
.../green/doc/examples/{fraction => frac}/gcd.hh | 0
.../doc/examples/{fraction => frac}/sign_prod.hh | 0
.../green/doc/examples/fraction/Makefile.am | 49 -------
.../milena/sandbox/green/mln/accu/stat/histo1d.hh | 57 +++++---
.../sandbox/green/mln/accu/stat/histo3d_hsl.hh | 4 +-
.../sandbox/green/mln/accu/stat/histo3d_rgb.hh | 56 +++++---
.../sandbox/green/mln/io/plot/save_histo_sh.hh | 10 +-
.../green/tests/accu/stat/histo1d/histo1d.cc | 14 +-
.../tests/accu/stat/histo3d_hsl/histo3d_hsl.cc | 19 ++--
.../tests/accu/stat/histo3d_rgb/histo3d_rgb.cc | 12 +-
14 files changed, 287 insertions(+), 117 deletions(-)
create mode 100644 trunk/milena/sandbox/green/doc/examples/frac/Makefile.am
rename trunk/milena/sandbox/green/doc/examples/{fraction => frac}/frac.cc (100%)
rename trunk/milena/sandbox/green/doc/examples/{fraction => frac}/frac.hh (100%)
rename trunk/milena/sandbox/green/doc/examples/{fraction => frac}/gcd.hh (100%)
rename trunk/milena/sandbox/green/doc/examples/{fraction => frac}/sign_prod.hh (100%)
delete mode 100644 trunk/milena/sandbox/green/doc/examples/fraction/Makefile.am
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index cc14c70..cb4de1e 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -8,6 +8,41 @@
2009-09-22 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Prepare demo for theo and questions for guillaume.
+
+ Rename fraction directory into frac directory.
+
+ * green/doc/examples/fraction/frac.cc : Delete.
+ * green/doc/examples/fraction/frac.hh : Delete.
+ * green/doc/examples/fraction/gcd.hh : Delete
+ * green/doc/examples/fraction/sign_prod.hh : Delete.
+
+ * green/doc/examples/frac/frac.cc : New.
+ * green/doc/examples/frac/frac.hh : New.
+ * green/doc/examples/frac/gcd.hh : New.
+ * green/doc/examples/frac/sign_prod.hh : New.
+ * green/doc/examples/frac/Makefile.am : New.
+
+ Collect some tmp results.
+
+ * green/mln/io/plot/save_histo_sh.hh
+ (save_histo_sh<2d>) : Comment method.
+ * green/mln/mln/accu/stat/histo1d.hh
+ : Update documentation.
+ * green/mln/mln/accu/stat/histo3d_rgb.hh
+ : Update documentation.
+ * green/mln/mln/accu/stat/histo3d_hsl.hh
+ : Update documentation.
+ * green/mln/tests/accu/stat/histo1d/histo1d.cc
+ (test_8bits_integration, main) : Comment unused code, save tmp results.
+ (test_8bits_operator_equal) : Test infer "!=" operator.
+ * green/mln/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
+ (test_integration, main) : Comment unused code, save tmp results.
+ * green/mln/tests/accu/stat/histo3d_hsl/histo3d_hsl.cc
+ (test_integration, main) : Comment unused code, save tmp results.
+
+2009-09-22 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Adapt styles. Need some 2d code.
* green/mln/io/plot/save_histo_sh.hh (save_histo_sh<2d>) : New func.
diff --git a/trunk/milena/sandbox/green/doc/examples/frac/Makefile.am b/trunk/milena/sandbox/green/doc/examples/frac/Makefile.am
new file mode 100644
index 0000000..d970989
--- /dev/null
+++ b/trunk/milena/sandbox/green/doc/examples/frac/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/doc/examples/fraction/frac.cc b/trunk/milena/sandbox/green/doc/examples/frac/frac.cc
similarity index 100%
rename from trunk/milena/sandbox/green/doc/examples/fraction/frac.cc
rename to trunk/milena/sandbox/green/doc/examples/frac/frac.cc
diff --git a/trunk/milena/sandbox/green/doc/examples/fraction/frac.hh b/trunk/milena/sandbox/green/doc/examples/frac/frac.hh
similarity index 100%
rename from trunk/milena/sandbox/green/doc/examples/fraction/frac.hh
rename to trunk/milena/sandbox/green/doc/examples/frac/frac.hh
diff --git a/trunk/milena/sandbox/green/doc/examples/fraction/gcd.hh b/trunk/milena/sandbox/green/doc/examples/frac/gcd.hh
similarity index 100%
rename from trunk/milena/sandbox/green/doc/examples/fraction/gcd.hh
rename to trunk/milena/sandbox/green/doc/examples/frac/gcd.hh
diff --git a/trunk/milena/sandbox/green/doc/examples/fraction/sign_prod.hh b/trunk/milena/sandbox/green/doc/examples/frac/sign_prod.hh
similarity index 100%
rename from trunk/milena/sandbox/green/doc/examples/fraction/sign_prod.hh
rename to trunk/milena/sandbox/green/doc/examples/frac/sign_prod.hh
diff --git a/trunk/milena/sandbox/green/doc/examples/fraction/Makefile.am b/trunk/milena/sandbox/green/doc/examples/fraction/Makefile.am
deleted file mode 100644
index 36a83e3..0000000
--- a/trunk/milena/sandbox/green/doc/examples/fraction/Makefile.am
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Generic Makefile
-#
-
-BIN_PATTERN= trunk/build/milena
-SRC_PATTERN= trunk/milena
-
-CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe
-ECHO= echo
-RM= rm
-MKDIR= mkdir
-CP= cp
-
-ifeq ($(findstring $(BIN_PATTERN),$(PWD)), $(BIN_PATTERN))
-BIN_DIR=
-SRC_DIR= $(subst $(BIN_PATTERN),$(SRC_PATTERN), $(PWD))/
-else
-BIN_DIR= $(subst $(SRC_PATTERN),$(BIN_PATTERN), $(PWD))/
-SRC_DIR=
-endif
-
-TARGET= $(BIN_DIR)$(notdir $(PWD))
-BIN_MAKE= $(BIN_DIR)Makefile
-SRC_MAKE= $(SRC_DIR)Makefile.am
-
-
-SRC_FILES= $(wildcard $(SRC_DIR)*.cc)
-OLD_FILES= $(addsuffix ~, $(SRC_FILES))
-OBJ_FILES= $(addprefix $(BIN_DIR), $(notdir $(SRC_FILES:%.cc=%.o)))
-
-
-all: $(BIN_DIR) $(TARGET)
- @$(ECHO) "Compilation terminée"
-
-$(BIN_DIR):
- $(MKDIR) $(BIN_DIR)
- $(CP) $(SRC_MAKE) $(BIN_MAKE)
-
-$(TARGET):$(OBJ_FILES)
- $(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
-
-$(BIN_DIR)%.o:$(SRC_DIR)%.cc
- $(COMPILE.cc) $(OUTPUT_OPTION) $<
-
-clean:
- -@$(RM) $(TARGET)
- -@$(RM) $(OBJ_FILES)
- -@$(RM) $(OLD_FILES)
-
diff --git a/trunk/milena/sandbox/green/mln/accu/stat/histo1d.hh b/trunk/milena/sandbox/green/mln/accu/stat/histo1d.hh
index 541b749..807f3bd 100644
--- a/trunk/milena/sandbox/green/mln/accu/stat/histo1d.hh
+++ b/trunk/milena/sandbox/green/mln/accu/stat/histo1d.hh
@@ -33,7 +33,7 @@
/// \brief Define a histogram as an accumulator which returns an image1d .
///
/// This source implements the discrete histogram version. The number of beans
-/// is infer from the number of greylevels. A typical int_u8 image has got
+/// is infer from the number of graylevels. A typical int_u8 image has got
/// 256 bins. An int_u<14> image has got 16384 bins.
/// The following sample is a typical use of the histogram.
///
@@ -43,9 +43,8 @@
/// #include <mln/io/pgm/load.hh>
/// #include <mln/accu/stat/histo1d.hh>
/// #include <mln/data/compute.hh>
-/// #include <mln/io/plot/save_histo_sh.hh>
///
-/// #define OLENA_LENA ""/usr/local/share/olena/images/lena.pgm"
+/// #define OLENA_LENA "/usr/local/share/olena/images/lena.pgm"
///
/// void test()
/// {
@@ -54,7 +53,7 @@
/// mln::image1d<unsigned> img_res;
///
/// mln::io::pgm::load(img_ref, OLENA_LENA);
-/// img_res = mln::data::compute(mln::accu::stat::histo1d<int_u8>(), img_ref);
+/// img_res = mln::data::compute(mln::accu::meta::stat::histo1d(), img_ref);
/// }
@@ -64,6 +63,7 @@
#include <mln/core/macros.hh>
#include <mln/core/image/image1d.hh>
+#include <mln/core/concept/meta_accumulator.hh>
#include <mln/trait/value/comp.hh>
@@ -89,8 +89,27 @@ namespace mln
} // end of namespace mln::accu::stat
- } // end of namespace mln::accu
+ namespace meta
+ {
+
+ namespace stat
+ {
+
+ struct histo1d : public Meta_Accumulator<histo1d>
+ {
+ template <typename V>
+ struct with
+ {
+ typedef accu::stat::histo1d<V> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta::stat
+
+ } // end of namespace mln::accu::meta
+
+ } // end of namespace mln::accu
namespace trait
{
@@ -123,9 +142,9 @@ namespace mln
/// \brief Define an histogram which returns an image1d .
///
/// Param V defines the space in which we count the values.
- /// For instance, this histogram works image2d<int_u8> or
+ /// For instance, this histogram works with image2d<int_u8> or with
/// image1d<int_u<14> >. The histogram count the occurrence of each value.
- /// The number of bins depends of the greyscale values, for 8 bits there
+ /// The number of bins depends of the graylevel values, for 8 bits there
/// is 256 bins, for 14 bits there is 16384 bins. Note that over
/// quantification works too (up to 14 bits).
///
@@ -144,7 +163,7 @@ namespace mln
/// \brief Initialize the size of the resulting image1d.
///
/// Initialize the size the resulting image from the theorical dynamic
- /// of the greylevel values (Use V to manage it).
+ /// of the graylevel values (Use V to manage it).
histo1d();
/// \}
@@ -159,8 +178,8 @@ namespace mln
void init();
- /// \brief Update the histogram with the greylevel of the pixel t.
- /// \param[in] t a greylevel pixel of type V.
+ /// \brief Update the histogram with the graylevel of the pixel t.
+ /// \param[in] t a graylevel pixel of type V.
///
/// The end user shouldn't call this method. In place of it, he can
/// go through the data compute interface.
@@ -169,6 +188,10 @@ namespace mln
/// \brief Update the histogram with an other histogram.
/// \param[in] other the other histogram.
+ ///
+ /// The end user shouldn't call this method. This is part of
+ /// data compute interface mechanism.
+
void take(const histo1d<V>& other);
/// \}
@@ -196,7 +219,7 @@ namespace mln
/// \param[in] histo1 the first histogram to compare with.
/// \param[in] histo2 the second histogram.
///
- /// The operator compare all the bins from the two histogram.
+ /// The operator compare all the bins from the two histograms.
template <typename V>
bool operator==(const histo1d<V>& histo1, const histo1d<V>& histo2);
@@ -219,17 +242,9 @@ namespace mln
count_.init_(box1d(point1d(mln_min(comp)),
point1d(mln_max(comp))));
- // std::cout << "min : " << mln_min(comp) << std::endl;
+ // std::cout << "min : " << mln_min(comp) << std::endl;
// std::cout << "max : " << mln_max(comp) << std::endl;
- // std::cout << "min : " << v_point1d(mln_min(comp)) << std::endl;
- // std::cout << "max : " << v_point1d(mln_max(comp)) << std::endl;
-
- //count_.init_(v_box1d(v_point1d(mln_min(comp)),
- // v_point1d(mln_max(comp))));
- // this does not work as image1d is friendly close to box1d
-
-
trace::exiting("mln::accu::stat::histo1d<V>::histo1d");
}
@@ -249,7 +264,7 @@ namespace mln
{
trace::entering("mln::accu::stat::histo1d<V>::take");
- // Just convert a greyscale value (int_u8 like) to a position for an
+ // Just convert a graylevel value (int_u8 like) to a position for an
// iterator on the resulting image.
++count_(point1d(t));
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 f29a725..c84aaa4 100644
--- a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
+++ b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
@@ -280,7 +280,7 @@ namespace mln
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;
@@ -293,7 +293,7 @@ namespace mln
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/mln/accu/stat/histo3d_rgb.hh b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
index 461870a..3f6411e 100644
--- a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
+++ b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
@@ -33,28 +33,27 @@
/// \brief Define a histogram as an accumulator which returns an image1d .
///
/// This source implements the discrete histogram version. The number of beans
-/// is infer from the number of greylevels. A typical int_u8 image has got
-/// 256 bins. An int_u16 image has got 65535 bins.
+/// is infer from the number of greylevels. A typical rgb8 image has got
+/// 256x3 bins. Working with a 8 bit quantification in rgb is very costly.
/// The following sample is a typical use of the histogram.
///
-/// #include <mln/value/int_u8.hh>
+/// #include <mln/value/rgb.hh>
/// #include <mln/core/image/image1d.hh>
-/// #include <mln/core/image/image2d.hh>
-/// #include <mln/io/pgm/load.hh>
-/// #include <mln/accu/stat/histo1d.hh>
+/// #include <mln/core/image/image3d.hh>
+/// #include <mln/io/ppm/load.hh>
+/// #include <mln/accu/stat/histo3d_rgb.hh>
/// #include <mln/data/compute.hh>
-/// #include <mln/io/plot/save_histo_sh.hh>
///
-/// #define OLENA_LENA ""/usr/local/share/olena/images/lena.pgm"
+/// #define OLENA_LENA ""/usr/local/share/olena/images/lena.ppm"
///
/// void test()
/// {
-/// typedef mln::value::int_u8 int_u8;
-/// mln::image2d<int_u8> img_ref;
-/// mln::image1d<unsigned> img_res;
+/// typedef mln::value::rgb<7> rgb7;
+/// mln::image2d<rgb7> img_ref;
+/// mln::image3d<unsigned> img_res;
///
-/// mln::io::pgm::load(img_ref, OLENA_LENA);
-/// img_res = mln::data::compute(mln::accu::stat::histo1d<int_u8>(), img_ref);
+/// mln::io::ppm::load(img_ref, OLENA_LENA);
+/// img_res=mln::data::compute(mln::accu::meta::stat::histo3d_rgb(),img_ref);
/// }
@@ -90,7 +89,26 @@ namespace mln
struct histo3d_rgb;
} // end of namespace mln::accu::stat
-
+
+ namespace meta
+ {
+
+ namespace stat
+ {
+
+ struct histo3d_rgb : public Meta_Accumulator<histo3d_rgb>
+ {
+ template <typename V>
+ struct with
+ {
+ typedef accu::stat::histo3d_rgb<V> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta::stat
+
+ } // end of namespace mln::accu::meta
+
} // end of namespace mln::accu
@@ -122,13 +140,13 @@ namespace mln
namespace stat
{
- /// \brief Define an histogram which returns an image1d .
+ /// \brief Define an histogram which returns an image3d .
///
/// Param V defines the space in which we count the values.
- /// For instance, this histogram works image2d<int_u8> or
- /// image1d<int_u16>. The histogram count the occurrence of each value.
- /// The number of bins depends of the greyscale values, for 8 bits there
- /// is 256 bins, for 16 bits there is 65536 bins. Note that over
+ /// For instance, this histogram works image2d<rgb<2>> or
+ /// image2d<rgb<7>>. The histogram count the occurrence of each value.
+ /// The number of bins depends of the grayscale values, for 8 bits there
+ /// is 256x3 bins. Note that over
/// quantification works too.
///
/// \ingroup modaccuvalues
diff --git a/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh b/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh
index cfd3446..111949a 100644
--- a/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh
+++ b/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh
@@ -63,8 +63,8 @@ namespace mln
void save_histo_sh(const image1d<I>& img, const std::string& filename);
- template <typename I>
- void save_histo_sh(const image2d<I>& img, const std::string& filename);
+ //template <typename I>
+ //void save_histo_sh(const image2d<I>& img, const std::string& filename);
/// \brief Save an histogram image3d as a gnuplot script shell.
/// \param[in] img the 3d image which contains the data to save.
@@ -123,7 +123,7 @@ namespace mln
out.close();
trace::exiting("mln::io::plot::save_histo_sh<1d>");
}
-
+ /*
template <typename I>
inline
void save_histo_sh(const image2d<I>& img, const std::string& filename)
@@ -157,7 +157,7 @@ namespace mln
trace::exiting("mln::io::plot::save_histo_sh<2d>");
}
-
+ */
template <typename I>
inline
void save_histo_sh(const image3d<I>& img, const std::string& filename)
@@ -183,7 +183,7 @@ namespace mln
out << p.row() << " ";
out << p.col() << " ";
out << p.sli() << " ";
- out << img(p) << std::endl;
+ out << img(p) << std::endl;
}
out << "e" << std::endl;
out << "EOF" << std::endl;
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo1d/histo1d.cc b/trunk/milena/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
index e959cbd..71266d1 100644
--- a/trunk/milena/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
@@ -74,8 +74,7 @@ void test_8bits_operator_equal()
histo1.take(val);
- /// FIXME mln_assertion(histo1 != histo2); doesn't work!!
- mln_assertion(!(histo1 == histo2));
+ mln_assertion(histo1 != histo2);
histo2.take(val);
@@ -259,7 +258,8 @@ void test_8bits_integration()
const double mean_ref = mln::data::compute(mean(), img_ref);
const double var_ref = mln::data::compute(variance(), img_ref);
- img_res = mln::data::compute(mln::accu::stat::histo1d<int_u8>(), img_ref);
+ img_res = mln::data::compute(mln::accu::meta::stat::histo1d(), img_ref);
+ // img_res = mln::data::compute(mln::accu::stat::histo1d<int_u8>(), img_ref);
const double count_res = count_histo(img_res);
const double mean_res = mean_histo(img_res);
@@ -678,15 +678,17 @@ void test_14bits_classifying()
int main()
{
+ test_8bits_operator_equal();
/*
test_8bits_instantiation_without_argument();
test_8bits_initialization();
test_8bits_take_argument();
test_8bits_take_other();
test_8bits_operator_equal();
- test_8bits_integration();
*/
- test_8bits_classifying();
+ //test_8bits_integration();
+
+ //test_8bits_classifying();
// PROBLEME AVEC LES COORDONNEES PAR DEFAUT QUI SONT EN SIGNED SHORT
// SEE mln/core/def/coord.hh
@@ -698,7 +700,7 @@ int main()
test_14bits_operator_equal();
test_14bits_integration();
*/
- test_14bits_classifying();
+ //test_14bits_classifying();
return 0;
}
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 47b3900..0a12706 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
@@ -330,13 +330,13 @@ void test_integration()
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_thd = mln::data::transform(img_sec,mln::fun::v2v::f_rgb_to_hsl_<hsl_f>());
+ 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_thd = mln::data::transform(img_fst,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");
+ //img_sav = mln::data::transform(img_thd, hslf_2_h());
+ //mln::io::plot::save_histo_sh(img_sav, "lena2.sh");
img_ref = mln::data::transform(img_thd, hslf_2_vec3f());
@@ -347,7 +347,7 @@ void test_integration()
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");
+ mln::io::plot::save_histo_sh(img_res, "histo_hsl.sh");
const double count_res = count_histo(img_res);
const vec3f mean_res = mean_histo(img_res, q);
@@ -410,13 +410,14 @@ void test()
int main()
{
-
+ /*
test_operator_equal<3>();
test_instantiation_without_argument<3>();
test_initialization<3>();
test_take_argument<3>();
test_take_other<3>();
- test_integration<3,7>();
+ */
+ test_integration<7,6>();
return 0;
}
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 eb87332..cbf273b 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
@@ -9,6 +9,7 @@
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
#include <mln/io/plot/save.hh>
+#include <mln/io/plot/save_histo_sh.hh>
#include <mln/data/compute.hh>
#include <mln/data/transform.hh>
@@ -279,6 +280,7 @@ void test_integration()
img_res = mln::data::compute(mln::accu::stat::histo3d_rgb<rgbn>(), img_ref);
+ mln::io::plot::save_histo_sh(img_res, "histo_rgb.sh");
const double count_res = count_histo(img_res);
const vec3f mean_res = mean_histo(img_res);
@@ -329,14 +331,14 @@ int main()
test_take_other<1>();
test_integration<1>();
*/
-
+ /*
test_operator_equal<2>();
test_instantiation_without_argument<2>();
test_initialization<2>();
test_take_argument<2>();
test_take_other<2>();
test_integration<2>();
-
+ */
/*
test_operator_equal<3>();
test_instantiation_without_argument<3>();
@@ -361,14 +363,14 @@ int main()
test_take_argument<5>();
test_take_other<5>();
test_integration<5>();
-
+ */
test_operator_equal<6>();
test_instantiation_without_argument<6>();
test_initialization<6>();
test_take_argument<6>();
test_take_other<6>();
test_integration<6>();
- */
+
/*
test_operator_equal<7>();
test_instantiation_without_argument<7>();
@@ -392,7 +394,5 @@ int main()
*/
- // p2p/fold+transform_domain for hcv
-
return 0;
}
--
1.5.6.5
1
0
* fabien/mln/upsampling/hq2x.hh,
* fabien/mln/upsampling/hq3x.hh,
* fabien/mln/upsampling/hq4x.hh: Fix invalid output domain.
---
milena/sandbox/ChangeLog | 18 +++++++++++++-----
milena/sandbox/fabien/mln/upsampling/hq2x.hh | 5 +++--
milena/sandbox/fabien/mln/upsampling/hq3x.hh | 4 +++-
milena/sandbox/fabien/mln/upsampling/hq4x.hh | 4 +++-
4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 16bbebb..cc14c70 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Fix invalid output domain in hq*x algorithms.
+
+ * fabien/mln/upsampling/hq2x.hh,
+ * fabien/mln/upsampling/hq3x.hh,
+ * fabien/mln/upsampling/hq4x.hh: Fix invalid output domain.
+
2009-09-22 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Adapt styles. Need some 2d code.
@@ -139,12 +147,12 @@
* green/doc/examples : New directory.
Move hello_world directory in doc/examples.
-
+
* green/doc/examples/hello_world : New directory.
* green/doc/examples/hello_world/Makefile.am : Copy makefile.
* green/doc/examples/hello_world/hellow_world.cc : Copy source file.
* green/doc/examples/hello_world/print.cc : Copy source file.
-
+
* green/hello_world/hello_world.cc : Remove source file.
* green/hello_world/print.cc : Remove source file.
* green/hello_world/Makefile.am : Remove makefile.
@@ -155,7 +163,7 @@
* green/doc/exampleshello_milena : New directory.
* green/doc/exampleshello_milena/Makefile.am : Copy makefile.
* green/doc/examples/hello_milena/hello_milena.cc : Copy source file.
-
+
* green/hello_milena/hello_milena.cc : Remove source file.
* green/hello_milena/Makefile.am : Remove makefile.
* green/hello_milena : Remove directory.
@@ -165,7 +173,7 @@
* green/doc/examples/learn_milena : New directory.
* green/doc/examples/learn_milena/Makefile.am : Copy makefile.
* green/doc/examples/learn_milena/learn_milena.cc : Copy source file.
-
+
* green/learn_milena/learn_milena.cc : Remove source file.
* green/learn_milena/Makefile.am : Remove makefile.
* green/learn_milena : Remove directory.
@@ -175,7 +183,7 @@
* green/doc/examples/otsu : New directory.
* green/doc/examples/otsu/Makefile.am : Copy makefile.
* green/doc/examples/otsu/otsu.cc : Copy source file.
-
+
* green/otsu/otsu.cc : Remove source file.
* green/otsu/Makefile.am : Remove makefile.
* green/otsu : Remove directory.
diff --git a/milena/sandbox/fabien/mln/upsampling/hq2x.hh b/milena/sandbox/fabien/mln/upsampling/hq2x.hh
index 78ed271..4368212 100644
--- a/milena/sandbox/fabien/mln/upsampling/hq2x.hh
+++ b/milena/sandbox/fabien/mln/upsampling/hq2x.hh
@@ -24,6 +24,7 @@
/// Reference can be found at:
/// http://web.archive.org/web/20070624082212/www.hiend3d.com/hq2x.html
+# include <mln/core/alias/dpoint2d.hh>
# include <mln/extension/adjust_duplicate.hh>
# include <mln/geom/max_col.hh>
# include <mln/geom/max_row.hh>
@@ -237,8 +238,8 @@ namespace mln
{
trace::entering("upsampling::impl::hq2x_");
- mln_domain(image2d<T>) bbox(input.domain().pmin() * 4,
- input.domain().pmax() * 4);
+ mln_domain(image2d<T>) bbox(input.domain().pmin() * 2,
+ input.domain().pmax() * 2 + mln::down_right);
mln_concrete(image2d<T>) output(bbox);
int LUT16to32[65536];
diff --git a/milena/sandbox/fabien/mln/upsampling/hq3x.hh b/milena/sandbox/fabien/mln/upsampling/hq3x.hh
index 15c1e65..940fe61 100644
--- a/milena/sandbox/fabien/mln/upsampling/hq3x.hh
+++ b/milena/sandbox/fabien/mln/upsampling/hq3x.hh
@@ -24,6 +24,7 @@
/// Reference can be found at:
/// http://web.archive.org/web/20070624082212/www.hiend3d.com/hq3x.html
+# include <mln/core/alias/dpoint2d.hh>
# include <mln/extension/adjust_duplicate.hh>
# include <mln/geom/max_col.hh>
# include <mln/geom/max_row.hh>
@@ -224,7 +225,8 @@ namespace mln
trace::entering("upsampling::impl::hq3x_");
mln_domain(image2d<T>) bbox(input.domain().pmin() * 3,
- input.domain().pmax() * 3);
+ input.domain().pmax() * 3
+ + 2 * mln::down_right);
mln_concrete(image2d<T>) output(bbox);
int LUT16to32[65536];
diff --git a/milena/sandbox/fabien/mln/upsampling/hq4x.hh b/milena/sandbox/fabien/mln/upsampling/hq4x.hh
index c77ef6a..1d091dc 100644
--- a/milena/sandbox/fabien/mln/upsampling/hq4x.hh
+++ b/milena/sandbox/fabien/mln/upsampling/hq4x.hh
@@ -24,6 +24,7 @@
/// Reference can be found at:
/// http://web.archive.org/web/20070624082212/www.hiend3d.com/hq4x.html
+# include <mln/core/alias/dpoint2d.hh>
# include <mln/extension/adjust_duplicate.hh>
# include <mln/geom/max_col.hh>
# include <mln/geom/max_row.hh>
@@ -344,7 +345,8 @@ namespace mln
trace::entering("upsampling::impl::hq4x_");
mln_domain(image2d<T>) bbox(input.domain().pmin() * 4,
- input.domain().pmax() * 4);
+ input.domain().pmax() * 4
+ + 3 * mln::down_right);
mln_concrete(image2d<T>) output(bbox);
int LUT16to32[65536];
--
1.5.6.5
1
0
---
ChangeLog | 4 ++++
configure.ac | 2 ++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2946671..10d4808 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ * configure.ac: Configure milena/tests/upscaling.
+
2009-09-21 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Filter results in QA Scripts.
diff --git a/configure.ac b/configure.ac
index efbbb27..4aa31d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -365,6 +365,8 @@ AC_CONFIG_FILES([
milena/tests/trait/value/Makefile
milena/tests/transform/Makefile
milena/tests/unit_test/Makefile
+ milena/tests/upscaling/Makefile
+ milena/tests/upscaling/art/Makefile
milena/tests/util/Makefile
milena/tests/value/Makefile
milena/tests/value/builtin/Makefile
--
1.5.6.5
1
0
* mln/upscaling/art/scale2x.hh,
* mln/upscaling/art/scale3x.hh: New routines.
* tests/Makefile.am,
* tests/upscaling/Makefile.am,
* tests/upscaling/art/Makefile.am,
* tests/upscaling/art/scale2x.cc,
* tests/upscaling/art/scale3x.cc: New associated tests.
---
milena/ChangeLog | 13 ++
milena/mln/upscaling/art/scale2x.hh | 151 ++++++++++++++++++++++
milena/mln/upscaling/art/scale3x.hh | 218 ++++++++++++++++++++++++++++++++
milena/tests/Makefile.am | 1 +
milena/tests/upscaling/Makefile.am | 24 ++++
milena/tests/upscaling/art/Makefile.am | 32 +++++
milena/tests/upscaling/art/scale2x.cc | 59 +++++++++
milena/tests/upscaling/art/scale3x.cc | 61 +++++++++
8 files changed, 559 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/upscaling/art/scale2x.hh
create mode 100644 milena/mln/upscaling/art/scale3x.hh
create mode 100644 milena/tests/upscaling/Makefile.am
create mode 100644 milena/tests/upscaling/art/Makefile.am
create mode 100644 milena/tests/upscaling/art/scale2x.cc
create mode 100644 milena/tests/upscaling/art/scale3x.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3100c37..19c3edd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add new upscaling algorithms.
+
+ * mln/upscaling/art/scale2x.hh,
+ * mln/upscaling/art/scale3x.hh: New routines.
+
+ * tests/Makefile.am,
+ * tests/upscaling/Makefile.am,
+ * tests/upscaling/art/Makefile.am,
+ * tests/upscaling/art/scale2x.cc,
+ * tests/upscaling/art/scale3x.cc: New associated tests.
+
+2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
* mln/core/alias/dpoint2d.hh: Add new dpoint2d aliases.
2009-09-22 Fabien Freling <fabien.freling(a)lrde.epita.fr>
diff --git a/milena/mln/upscaling/art/scale2x.hh b/milena/mln/upscaling/art/scale2x.hh
new file mode 100644
index 0000000..6805943
--- /dev/null
+++ b/milena/mln/upscaling/art/scale2x.hh
@@ -0,0 +1,151 @@
+// 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_UPSCALING_ART_SCALE2X_HH
+# define MLN_UPSCALING_ART_SCALE2X_HH
+
+/// \file
+///
+/// 2X upscaling algorithm for pixel art images.
+
+
+# include <mln/core/concept/box.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/alias/dpoint2d.hh>
+
+# include <mln/extension/adjust_duplicate.hh>
+
+
+namespace mln
+{
+
+ namespace upscaling
+ {
+
+ namespace art
+ {
+
+ /*! \brief 2X upscaling algorithm for pixel art images.
+
+ \param[in] input An image.
+
+ \return An upscaled image.
+
+
+ Source:
+ http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ scale2x(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ mln_concrete(I)
+ scale2x(const Image<I>& input_)
+ {
+ trace::entering("mln::upscaling::art::scale2x");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ extension::adjust_duplicate(input, 1);
+
+ mln_domain(I) ext_domain(input.domain().pmin() * 2,
+ input.domain().pmax() * 2
+ + mln::down_right);
+
+ mln_concrete(I) output(ext_domain);
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ {
+
+ // A --\ 1 2
+ // C P B --/ 3 4
+ // D
+ mln_site(I)
+ pA = p + mln::up,
+ pB = p + mln::right,
+ pC = p + mln::left,
+ pD = p + mln::down,
+ pOut = p * 2;
+
+ // IF C==A AND C!=D AND A!=B => 1=A
+ if (input(pC) == input(pA)
+ && input(pC) != input(pD)
+ && input(pA) != input(pB))
+ output(pOut) = input(pA);
+ else
+ output(pOut) = input(p);
+
+ // IF A==B AND A!=C AND B!=D => 2=B
+ if (input(pA) == input(pB)
+ && input(pA) != input(pC)
+ && input(pB) != input(pD))
+ output(pOut + mln::right) = input(pB);
+ else
+ output(pOut + mln::right) = input(p);
+
+ // IF D==C AND D!=B AND C!=A => 3=C
+ if (input(pD) == input(pC)
+ && input(pD) != input(pB)
+ && input(pC) != input(pA))
+ output(pOut + mln::down) = input(pC);
+ else
+ output(pOut + mln::down) = input(p);
+
+ // IF B==D AND B!=A AND D!=C => 4=D
+ if (input(pB) == input(pD)
+ && input(pB) != input(pA)
+ && input(pD) != input(pC))
+ output(pOut + mln::down_right) = input(pD);
+ else
+ output(pOut + mln::down_right) = input(p);
+
+ }
+
+ trace::exiting("mln::upscaling::art::scale2x");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::upscaling::art
+
+ } // end of namespace mln::upscaling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UPSCALING_ART_SCALE2X_HH
diff --git a/milena/mln/upscaling/art/scale3x.hh b/milena/mln/upscaling/art/scale3x.hh
new file mode 100644
index 0000000..042dd28
--- /dev/null
+++ b/milena/mln/upscaling/art/scale3x.hh
@@ -0,0 +1,218 @@
+// 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_UPSCALING_ART_SCALE3X_HH
+# define MLN_UPSCALING_ART_SCALE3X_HH
+
+/// \file
+///
+/// 3X upscaling algorithm for pixel art images.
+
+
+# include <mln/core/concept/box.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/alias/dpoint2d.hh>
+
+# include <mln/extension/adjust_duplicate.hh>
+
+
+namespace mln
+{
+
+ namespace upscaling
+ {
+
+ namespace art
+ {
+
+ /*! \brief 3X upscaling algorithm for pixel art images.
+
+ \param[in] input An image.
+
+ \return An upscaled image.
+
+
+ Source:
+ http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ scale3x(const Image<I>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ mln_concrete(I)
+ scale3x(const Image<I>& input_)
+ {
+ trace::entering("mln::upscaling::art::scale3x");
+
+ const I& input = exact(input_);
+ mln_precondition(input.is_valid());
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ extension::adjust_duplicate(input, 1);
+
+ mln_domain(I) ext_domain(input.domain().pmin() * 3,
+ input.domain().pmax() * 3
+ + 2 * mln::down_right);
+
+ mln_concrete(I) output(ext_domain);
+
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ {
+
+ // A B C --\ 1 2 3
+ // D E F > 4 5 6
+ // G H I --/ 7 8 9
+ mln_site(I)
+ pA = p + mln::up_left,
+ pB = p + mln::up,
+ pC = p + mln::up_right,
+ pD = p + mln::left,
+ pE = p,
+ pF = p + mln::right,
+ pG = p + mln::down_left,
+ pH = p + mln::down,
+ pI = p + mln::down_right,
+ pOut = p * 3 + mln::down_right;
+
+ // IF D==B AND D!=H AND B!=F => 1=D
+ if (input(pD) == input(pB)
+ && input(pD) != input(pH)
+ && input(pB) != input(pF))
+ output(pOut + mln::up_left) = input(pD);
+ else
+ output(pOut + mln::up_left) = input(p);
+
+ // IF (D==B AND D!=H AND B!=F AND E!=C) OR (B==F AND B!=D
+ // AND F!=H AND E!=A) 2=B
+ if ((input(pD) == input(pB)
+ && input(pD) != input(pH)
+ && input(pB) != input(pF)
+ && input(pE) != input(pC))
+ || (input(pB) == input(pF)
+ && input(pB) != input(pD)
+ && input(pF) != input(pH)
+ && input(pE) != input(pA)))
+ output(pOut + mln::up) = input(pB);
+ else
+ output(pOut + mln::up) = input(p);
+
+ // IF B==F AND B!=D AND F!=H => 3=F
+ if (input(pB) == input(pF)
+ && input(pB) != input(pD)
+ && input(pF) != input(pH))
+ output(pOut + mln::up_right) = input(pF);
+ else
+ output(pOut + mln::up_right) = input(p);
+
+ // IF (H==D AND H!=F AND D!=B AND E!=A) OR (D==B AND D!=H
+ // AND B!=F AND E!=G) 4=D
+ if ((input(pH) == input(pD)
+ && input(pH) != input(pF)
+ && input(pD) != input(pB)
+ && input(pE) != input(pA))
+ || (input(pD) == input(pB)
+ && input(pD) != input(pH)
+ && input(pB) != input(pF)
+ && input(pE) != input(pG)))
+ output(pOut + mln::left) = input(pD);
+ else
+ output(pOut + mln::left) = input(p);
+
+ // 5=E
+ output(pOut) = input(p);
+
+ // IF (B==F AND B!=D AND F!=H AND E!=I) OR (F==H AND F!=B
+ // AND H!=D AND E!=C) 6=F
+ if ((input(pB) == input(pF)
+ && input(pB) != input(pD)
+ && input(pF) != input(pH)
+ && input(pE) != input(pI))
+ || (input(pF) == input(pH)
+ && input(pF) != input(pB)
+ && input(pH) != input(pD)
+ && input(pE) != input(pC)))
+ output(pOut + mln::right) = input(pF);
+ else
+ output(pOut + mln::right) = input(p);
+
+ // IF H==D AND H!=F AND D!=B => 7=D
+ if (input(pH) == input(pD)
+ && input(pH) != input(pF)
+ && input(pD) != input(pB))
+ output(pOut + mln::down_left) = input(pD);
+ else
+ output(pOut + mln::down_left) = input(p);
+
+
+ // IF (F==H AND F!=B AND H!=D AND E!=G) OR (H==D AND H!=F
+ // AND D!=B AND E!=I) 8=H
+ if ((input(pF) == input(pH)
+ && input(pF) != input(pB)
+ && input(pH) != input(pD)
+ && input(pE) != input(pG))
+ || (input(pH) == input(pD)
+ && input(pH) != input(pF)
+ && input(pD) != input(pB)
+ && input(pE) != input(pI)))
+ output(pOut + mln::down) = input(pH);
+ else
+ output(pOut + mln::down) = input(p);
+
+
+ // IF F==H AND F!=B AND H!=D => 9=F
+ if (input(pF) == input(pH)
+ && input(pF) != input(pB)
+ && input(pH) != input(pD))
+ output(pOut + mln::down_right) = input(pF);
+ else
+ output(pOut + mln::down_right) = input(p);
+
+ }
+
+ trace::exiting("mln::upscaling::art::scale3x");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::upscaling::art
+
+ } // end of namespace mln::upscaling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UPSCALING_ART_SCALE3X_HH
diff --git a/milena/tests/Makefile.am b/milena/tests/Makefile.am
index 39987d0..562078e 100644
--- a/milena/tests/Makefile.am
+++ b/milena/tests/Makefile.am
@@ -59,6 +59,7 @@ SUBDIRS = \
trait \
transform \
unit_test \
+ upscaling \
util \
value \
win \
diff --git a/milena/tests/upscaling/Makefile.am b/milena/tests/upscaling/Makefile.am
new file mode 100644
index 0000000..dbe5a89
--- /dev/null
+++ b/milena/tests/upscaling/Makefile.am
@@ -0,0 +1,24 @@
+# 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/>.
+#
+
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = \
+ art
+
diff --git a/milena/tests/upscaling/art/Makefile.am b/milena/tests/upscaling/art/Makefile.am
new file mode 100644
index 0000000..e001aaa
--- /dev/null
+++ b/milena/tests/upscaling/art/Makefile.am
@@ -0,0 +1,32 @@
+# 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/>.
+#
+
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+
+check_PROGRAMS = \
+ scale2x \
+ scale3x
+
+
+scale2x_SOURCES = scale2x.cc
+scale3x_SOURCES = scale3x.cc
+
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/upscaling/art/scale2x.cc b/milena/tests/upscaling/art/scale2x.cc
new file mode 100644
index 0000000..1db0298
--- /dev/null
+++ b/milena/tests/upscaling/art/scale2x.cc
@@ -0,0 +1,59 @@
+// 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 Test of the upscaling::art::scale2x routine.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/upscaling/art/scale2x.hh>
+
+int main()
+{
+ using namespace mln;
+
+ bool rvals[4][8] = {
+ {0, 0, 0, 0, 0, 0, 1, 1},
+ {0, 0, 0, 0, 0, 0, 1, 1},
+ {1, 1, 1, 0, 0, 0, 1, 1},
+ {1, 1, 1, 1, 0, 0, 1, 1},
+ };
+
+
+ bool vals[2][4] = {
+ {0, 0, 0, 1},
+ {1, 1, 0, 1}
+ };
+
+ image2d<bool> ref = make::image(rvals);
+ image2d<bool> input = make::image(vals);
+
+
+ input = upscaling::art::scale2x(input);
+
+ mln_assertion(input == ref);
+}
diff --git a/milena/tests/upscaling/art/scale3x.cc b/milena/tests/upscaling/art/scale3x.cc
new file mode 100644
index 0000000..dbcde5c
--- /dev/null
+++ b/milena/tests/upscaling/art/scale3x.cc
@@ -0,0 +1,61 @@
+// 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 Test of the upscaling::art::scale3x routine.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/upscaling/art/scale3x.hh>
+
+int main()
+{
+ using namespace mln;
+
+
+ bool rvals[6][12] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
+ {1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1},
+ {1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1},
+ {1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1}
+ };
+
+
+ bool vals[2][4] = {
+ {0, 0, 0, 1},
+ {1, 1, 0, 1}
+ };
+
+ image2d<bool> ref = make::image(rvals);
+ image2d<bool> input = make::image(vals);
+
+ input = upscaling::art::scale3x(input);
+
+ mln_assertion(input == ref);
+}
--
1.5.6.5
1
0
22 Sep '09
---
milena/ChangeLog | 4 ++++
milena/mln/core/alias/dpoint2d.hh | 13 ++++++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 21734a8..3100c37 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ * mln/core/alias/dpoint2d.hh: Add new dpoint2d aliases.
+
2009-09-22 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix HSL values in test.
diff --git a/milena/mln/core/alias/dpoint2d.hh b/milena/mln/core/alias/dpoint2d.hh
index 687ae55..2dbd864 100644
--- a/milena/mln/core/alias/dpoint2d.hh
+++ b/milena/mln/core/alias/dpoint2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -59,6 +60,11 @@ namespace mln
extern const dpoint2d left;
extern const dpoint2d right;
+ extern const dpoint2d up_left;
+ extern const dpoint2d up_right;
+ extern const dpoint2d down_left;
+ extern const dpoint2d down_right;
+
/// \}
@@ -70,6 +76,11 @@ namespace mln
const dpoint2d left = dpoint2d( 0, -1 );
const dpoint2d right = dpoint2d( 0, +1 );
+ const dpoint2d up_left = dpoint2d( -1, -1 );
+ const dpoint2d up_right = dpoint2d( -1, +1 );
+ const dpoint2d down_left = dpoint2d( +1, -1 );
+ const dpoint2d down_right = dpoint2d( +1, +1 );
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* green/mln/io/plot/save_histo_sh.hh (save_histo_sh<2d>) : New func.
---
trunk/milena/sandbox/ChangeLog | 6 +++
.../sandbox/green/mln/io/plot/save_histo_sh.hh | 42 +++++++++++++++++++-
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index 06426ad..16bbebb 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -1,5 +1,11 @@
2009-09-22 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Adapt styles. Need some 2d code.
+ * green/mln/io/plot/save_histo_sh.hh (save_histo_sh<2d>) : New func.
+
+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.
diff --git a/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh b/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh
index e2d26e1..cfd3446 100644
--- a/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh
+++ b/trunk/milena/sandbox/green/mln/io/plot/save_histo_sh.hh
@@ -62,6 +62,10 @@ namespace mln
template <typename I>
void save_histo_sh(const image1d<I>& img, const std::string& filename);
+
+ template <typename I>
+ void save_histo_sh(const image2d<I>& img, const std::string& filename);
+
/// \brief Save an histogram image3d as a gnuplot script shell.
/// \param[in] img the 3d image which contains the data to save.
/// \param[in] filename the name of the unix script shell.
@@ -122,13 +126,47 @@ namespace mln
template <typename I>
inline
+ void save_histo_sh(const image2d<I>& img, const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_histo_sh<2d>");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ mln_piter(image2d<I>) p(img.domain());
+
+ 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 << "set terminal x11 persist 1" << std::endl;
+ out << "splot '-' with points palette pointtype 0" << std::endl;
+
+ for_all(p)
+ //if (0 < img(p))
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+ out << "e" << std::endl;
+ out << "EOF" << std::endl;
+
+ out.close();
+ trace::exiting("mln::io::plot::save_histo_sh<2d>");
+ }
+
+
+ template <typename I>
+ inline
void save_histo_sh(const image3d<I>& img, const std::string& filename)
{
- trace::entering("mln::io::plot::save_histo_sh<3d>")
+ trace::entering("mln::io::plot::save_histo_sh<3d>");
mln_precondition(img.is_valid());
std::ofstream out(filename.c_str());
- mln_piter(I) p(img.domain());
+ mln_piter(image3d<I>) p(img.domain());
out << "#!/bin/sh" << std::endl;
out << "####################################" << std::endl;
--
1.5.6.5
1
0