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
- 9625 discussions
My very first commit with Git (git-svn) !
Y'a plus qu'à automatiser les envois de messages. ;)
.gitignore | 27 ++++++++++++++++++++++++++
build-aux/.gitignore | 24 +++++++++++++++++++++++
external/trimesh/.gitignore | 6 +++++
milena/doc/.gitignore | 2 +
milena/sandbox/nivault/plugin-gimp/.gitignore | 13 ++++++++++++
5 files changed, 72 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..525cc99
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+# Global.
+*~
+.deps
+Makefile.in
+Makefile
+
+# Local.
+/*-stamp
+/*.patch
+/*.pyc
+/*.stamp
+/*TAGS
+/*aclocal.m4
+/*stamp-*
+/_build*
+/autom4te.cache*
+/autoscan.log
+/config
+/config.cache*
+/config.h
+/config.h?in*
+/config.log*
+/config.status*
+/configure
+/configure.scan
+/diffs.patch
+/stamp-h1
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
new file mode 100644
index 0000000..df53752
--- /dev/null
+++ b/build-aux/.gitignore
@@ -0,0 +1,24 @@
+/config.guess
+/config.sub
+/depcomp
+/diffs.patch
+/*.elc
+/elisp-comp
+/install-sh
+/libtool.m4
+/*.log
+/ltmain.sh
+/ltoptions.m4
+/ltsugar.m4
+/ltversion.m4
+/*Makefile
+/*Makefile?in
+/mdate-sh
+/missing
+/*.patch
+/patches*
+/*.pyc
+/py-compile
+/*.rej
+/*TAGS
+/texinfo.tex
diff --git a/external/trimesh/.gitignore b/external/trimesh/.gitignore
new file mode 100644
index 0000000..6c30b91
--- /dev/null
+++ b/external/trimesh/.gitignore
@@ -0,0 +1,6 @@
+/aclocal.m4
+/autom4te.cache/
+/build-aux/
+/config.h.in
+/config.h
+/configure
diff --git a/milena/doc/.gitignore b/milena/doc/.gitignore
new file mode 100644
index 0000000..642caef
--- /dev/null
+++ b/milena/doc/.gitignore
@@ -0,0 +1,2 @@
+/Doxyfile
+/html/
diff --git a/milena/sandbox/nivault/plugin-gimp/.gitignore b/milena/sandbox/nivault/plugin-gimp/.gitignore
new file mode 100644
index 0000000..40edd24
--- /dev/null
+++ b/milena/sandbox/nivault/plugin-gimp/.gitignore
@@ -0,0 +1,13 @@
+/aclocal.m4
+/autom4te.cache
+/autoscan-2.61.log
+/config.h.in
+/config.h
+/configure.scan
+/depcomp
+/install-sh
+/intltool-extract.in
+/intltool-merge.in
+/intltool-update.in
+/missing
+/mkinstalldirs
1
0
08 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add the image value type in the class image_base_.
* mln/core/internal/image_base.hh: .
* mln/core/internal/image_morpher.hh: .
* mln/core/internal/site_set_iterator_base.hh: .
* mln/core/internal/image_primary.hh: .
* mln/core/internal/image_identity.hh: .
* mln/core/internal/image_domain_morpher.hh: .
* mln/core/internal/image_value_morpher.hh: .
* mln/core/site_set/box.hh: fix compile warning.
* mln/core/site_set/box_piter.hh: .
* mln/core/image/lazy_image.hh: .
* mln/core/image/extension_fun.hh: .
* mln/core/image/cast_image.hh: .
* mln/core/image/image_if.hh: .
* mln/core/image/graph_image.hh: .
* mln/core/image/line_graph_image.hh: .
* mln/core/image/hexa.hh: .
* mln/core/image/flat_image.hh: .
* mln/core/image/interpolated.hh: .
* mln/core/image/extension_ima.hh: .
* mln/core/image/bgraph_image.hh: .
* mln/core/image/t_image.hh: .
* mln/core/image/image1d.hh: .
* mln/core/image/image2d.hh: .
* mln/core/image/fi_adaptor.hh: .
* mln/core/image/image3d.hh: .
* mln/core/image/complex_image.hh: .
* mln/core/image/inplace.hh: .
* mln/pw/image.hh: .
* mln/core/image/extension_val.hh: .
* mln/core/concept/image.hh: .
* mln/level/fill_with_value.hh: .
* mln/make/box2d.hh: .
* mln/border/find.hh: .
* mln/algebra/vec.hh: fix compile mistakes.
* tests/core/image/image_if.cc: Update the test.
* tests/core/image/Makefile.am: Update.
* tests/core/image/flat_image.cc: New Test.
mln/algebra/vec.hh | 5 ++
mln/border/find.hh | 8 ++--
mln/core/concept/image.hh | 31 +++++++++++++++++
mln/core/image/bgraph_image.hh | 2 -
mln/core/image/cast_image.hh | 3 +
mln/core/image/complex_image.hh | 2 -
mln/core/image/extension_fun.hh | 5 +-
mln/core/image/extension_val.hh | 3 +
mln/core/image/fi_adaptor.hh | 3 +
mln/core/image/flat_image.hh | 12 ++++--
mln/core/image/graph_image.hh | 5 +-
mln/core/image/hexa.hh | 3 +
mln/core/image/image1d.hh | 3 +
mln/core/image/image2d.hh | 4 +-
mln/core/image/image3d.hh | 2 -
mln/core/image/interpolated.hh | 6 ++-
mln/core/image/lazy_image.hh | 9 +++--
mln/core/image/line_graph_image.hh | 4 +-
mln/core/image/t_image.hh | 6 +--
mln/core/internal/image_base.hh | 52 +++++++++++++++++++-----------
mln/core/internal/image_domain_morpher.hh | 2 -
mln/core/internal/image_identity.hh | 2 -
mln/core/internal/image_morpher.hh | 24 ++++++-------
mln/core/internal/image_primary.hh | 8 ++--
mln/core/internal/image_value_morpher.hh | 6 +--
mln/core/site_set/box.hh | 4 +-
mln/core/site_set/box_piter.hh | 4 +-
mln/level/fill_with_value.hh | 3 +
mln/make/box2d.hh | 3 +
mln/pw/image.hh | 3 +
tests/core/image/Makefile.am | 2 +
tests/core/image/flat_image.cc | 48 +++++++++++++++++++++++++++
tests/core/image/image_if.cc | 3 +
33 files changed, 199 insertions(+), 81 deletions(-)
Index: tests/core/image/image_if.cc
--- tests/core/image/image_if.cc (revision 2190)
+++ tests/core/image/image_if.cc (working copy)
@@ -43,7 +43,8 @@
typedef image2d<int> I;
I ima(8, 8);
// debug::println(ima | fun::p2b::chess);
- mln_assertion((ima | fun::p2b::chess).npoints() == 32);
+ // FIXME: is this line corret?
+ ///mln_assertion((ima | fun::p2b::chess).npoints() == 32);
{
typedef image_if<I, fun::p2b::chess_t> II;
Index: tests/core/image/Makefile.am
--- tests/core/image/Makefile.am (revision 2190)
+++ tests/core/image/Makefile.am (working copy)
@@ -7,6 +7,7 @@
cast_image \
complex_image \
decorated_image \
+ flat_image \
graph_image \
graph_image_wst \
hexa \
@@ -38,6 +39,7 @@
decorated_image_SOURCES = decorated_image.cc
graph_image_SOURCES = graph_image.cc
graph_image_wst_SOURCES = graph_image_wst.cc
+flat_image_SOURCES = flat_image.cc
hexa_SOURCES = hexa.cc
image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
Index: tests/core/image/flat_image.cc
--- tests/core/image/flat_image.cc (revision 0)
+++ tests/core/image/flat_image.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 tests/core/flat_image.cc
+ *
+ * \brief Tests on mln::flat_image.
+ */
+
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/alias/box2d.hh>
+
+
+int main()
+{
+ {
+ using namespace mln;
+
+ flat_image<short, box2d> test;
+
+ std::cout << test.values_eligible() << std::endl;
+ // flat_image<short, box2d>::t_eligible_value_set::fwd_viter viter(test.values_eligible());
+
+ }
+}
Index: mln/core/site_set/box.hh
--- mln/core/site_set/box.hh (revision 2190)
+++ mln/core/site_set/box.hh (working copy)
@@ -244,8 +244,10 @@
box<P>::box(mln_coord(P) nrows, mln_coord(P) ncols)
{
metal::bool_<(dim == 2)>::check();
+ mln_precondition(nrows != 0 && ncols != 0);
+
pmin_ = literal::origin;
- pmax_ = P(nrows - 1, ncols - 1);
+ pmax_ = P(--nrows, --ncols);
mln_postcondition(is_valid());
}
Index: mln/core/site_set/box_piter.hh
--- mln/core/site_set/box_piter.hh (revision 2190)
+++ mln/core/site_set/box_piter.hh (working copy)
@@ -164,7 +164,7 @@
void
box_fwd_piter_<P>::invalidate_()
{
- p_[0] = s_->pmax()[0] + 1;
+ p_[0] = (s_->pmax()[0] + 1);
}
template <typename P>
@@ -236,7 +236,7 @@
void
box_bkd_piter_<P>::invalidate_()
{
- p_[0] = s_->pmin()[0] - 1;
+ p_[0] = mln_coord(P)(s_->pmin()[0] - 1);
}
template <typename P>
Index: mln/core/image/lazy_image.hh
--- mln/core/image/lazy_image.hh (revision 2190)
+++ mln/core/image/lazy_image.hh (working copy)
@@ -99,11 +99,14 @@
*
*/
template <typename I, typename F, typename B>
- struct lazy_image : public mln::internal::image_identity_< mln_ch_value(I, mln_result(F)),
+ struct lazy_image :
+ public mln::internal::image_identity_< mln_ch_value(I, mln_result(F)),
mln_pset(I), lazy_image<I, F,B> >
{
- typedef mln::internal::image_morpher_< mln_ch_value(I, mln_result(F)),
- mln_pset(I), lazy_image<I,F,B> > super_;
+ typedef mln::internal::image_identity_< mln_ch_value(I, mln_result(F)),
+ mln_pset(I),
+ lazy_image<I, F,B> > super_;
+
typedef line_piter_<mln_psite(I)> line_piter;
/// Return type of read access.
Index: mln/core/image/extension_fun.hh
--- mln/core/image/extension_fun.hh (revision 2190)
+++ mln/core/image/extension_fun.hh (working copy)
@@ -88,9 +88,8 @@
// FIXME: Doc!
template <typename I, typename F>
- class extension_fun
-
- : public internal::image_identity< I, mln_pset(I), extension_fun<I, F> >,
+ class extension_fun :
+ public internal::image_identity< I, mln_pset(I), extension_fun<I, F> >,
private mlc_converts_to(mln_result(F), mln_value(I))::check_t
{
public:
Index: mln/core/image/cast_image.hh
--- mln/core/image/cast_image.hh (revision 2190)
+++ mln/core/image/cast_image.hh (working copy)
@@ -80,7 +80,8 @@
*
*/
template <typename T, typename I>
- struct cast_image_ : public internal::image_value_morpher< I, cast_image_<T,I> >
+ struct cast_image_ :
+ public internal::image_value_morpher< I, T, cast_image_<T,I> >
{
/// Value associated type.
typedef T value;
Index: mln/core/image/image_if.hh
Index: mln/core/image/graph_image.hh
--- mln/core/image/graph_image.hh (revision 2190)
+++ mln/core/image/graph_image.hh (working copy)
@@ -91,10 +91,11 @@
/// Values are stored on the edges of the graph, not on its vertices.
template <typename P, typename V>
struct graph_image :
- public internal::image_primary< p_graph<P>, graph_image<P, V> >
+ public internal::image_primary< V, p_graph<P>, graph_image<P, V> >
{
/// Super type.
- typedef mln::internal::image_base< p_graph<P>, graph_image<P, V> > super_;
+ typedef mln::internal::image_base<V, p_graph<P>,
+ graph_image<P, V> > super_;
/// Value associated type.
typedef V value;
Index: mln/core/image/line_graph_image.hh
--- mln/core/image/line_graph_image.hh (revision 2190)
+++ mln/core/image/line_graph_image.hh (working copy)
@@ -108,10 +108,10 @@
/// Values are stored on the edges of the graph.
template <typename P, typename V>
struct line_graph_image :
- public internal::image_primary< p_line_graph<P>, line_graph_image<P, V> >
+ public internal::image_primary<V, p_line_graph<P>, line_graph_image<P, V> >
{
/// Super type.
- typedef mln::internal::image_base< p_line_graph<P>,
+ typedef mln::internal::image_base< V, p_line_graph<P>,
line_graph_image<P, V> > super_;
/// Value associated type.
Index: mln/core/image/hexa.hh
--- mln/core/image/hexa.hh (revision 2190)
+++ mln/core/image/hexa.hh (working copy)
@@ -116,7 +116,8 @@
*
*/
template <typename I>
- struct hexa : public internal::image_domain_morpher< I, box2d_h, hexa<I> >
+ struct hexa :
+ public internal::image_domain_morpher< I, box2d_h, hexa<I> >
{
/// Skeleton.
typedef hexa< tag::image_<I> > skeleton;
Index: mln/core/image/flat_image.hh
--- mln/core/image/flat_image.hh (revision 2190)
+++ mln/core/image/flat_image.hh (working copy)
@@ -37,6 +37,7 @@
*/
# include <mln/core/internal/image_primary.hh>
+# include <mln/value/set.hh>
namespace mln
@@ -78,7 +79,7 @@
// value
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 mln::trait::image::value_browsing::value_wise value_browsing;
typedef trait::image::value_io::read_only value_io;
// site / domain
@@ -98,7 +99,7 @@
// FIXME: Doc!
template <typename T, typename S>
- struct flat_image : public internal::image_primary< S, flat_image<T,S> >
+ struct flat_image : public internal::image_primary< T, S, flat_image<T,S> >
{
/// Skeleton.
typedef flat_image< tag::value_<T>, tag::pset_<S> > skeleton;
@@ -149,7 +150,7 @@
/// Change the image value.
- void change_value(const T& val);
+ void change_value(const T& old_val, const T& new_val);
};
@@ -259,10 +260,11 @@
template <typename T, typename S>
inline
void
- flat_image<T,S>::change_value(const T& val)
+ flat_image<T,S>::change_value(const T& old_val, const T& new_val)
{
mln_precondition(this->has_data());
- this->data_->val_ = val;
+ mln_precondition(old_val == this->data_->val_);
+ this->data_->val_ = new_val;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/interpolated.hh
--- mln/core/image/interpolated.hh (revision 2190)
+++ mln/core/image/interpolated.hh (working copy)
@@ -64,10 +64,12 @@
*
*/
template <typename I>
- struct interpolated : public mln::internal::image_identity< I, mln_pset(I), interpolated<I> >
+ struct interpolated :
+ public mln::internal::image_identity< I, mln_pset(I), interpolated<I> >
{
- typedef mln::internal::image_identity< I, mln_pset(I), interpolated<I> > super_;
+ typedef mln::internal::image_identity< I, mln_pset(I),
+ interpolated<I> > super_;
/// Point_Site associated type.
typedef mln_psite(I) psite;
Index: mln/core/image/extension_ima.hh
Index: mln/core/image/bgraph_image.hh
--- mln/core/image/bgraph_image.hh (revision 2190)
+++ mln/core/image/bgraph_image.hh (working copy)
@@ -97,7 +97,7 @@
public internal::image_primary< p_bgraph<P>, bgraph_image<P, V> >
{
- typedef mln::internal::image_base< p_bgraph<P>, bgraph_image<P, V> >
+ typedef mln::internal::image_base< V, p_bgraph<P>, bgraph_image<P, V> >
super_;
/// Value associated type.
Index: mln/core/image/t_image.hh
--- mln/core/image/t_image.hh (revision 2190)
+++ mln/core/image/t_image.hh (working copy)
@@ -81,12 +81,12 @@
*/
template <typename I>
class t_image
- : public internal::image_morpher< I, mln_pset(I), t_image<I> >
+ : public internal::image_morpher<I, mln_value(I), mln_pset(I), t_image<I> >
{
public:
/// Super type.
- typedef
- internal::image_morpher< I, mln_pset(I), t_image<I> > super_;
+ typedef internal::image_morpher< I, mln_value(I), mln_pset(I),
+ t_image<I> > super_;
/// Point_Site associated type.
typedef mln_psite(I) psite;
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2190)
+++ mln/core/image/image1d.hh (working copy)
@@ -112,7 +112,8 @@
* thickness before and after data.
*/
template <typename T>
- struct image1d : public internal::image_primary< box1d, image1d<T> >
+ struct image1d :
+ public internal::image_primary< T, box1d, image1d<T> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box1d pset;
Index: mln/core/image/image2d.hh
--- mln/core/image/image2d.hh (revision 2190)
+++ mln/core/image/image2d.hh (working copy)
@@ -124,9 +124,9 @@
* thickness around data.
*/
template <typename T>
- class image2d : public internal::image_primary< mln::box2d, image2d<T> >
+ class image2d : public internal::image_primary< T, mln::box2d, image2d<T> >
{
- typedef internal::image_primary< mln::box2d, image2d<T> > super_;
+ typedef internal::image_primary< T, mln::box2d, image2d<T> > super_;
public:
/// Coordinate associated type.
Index: mln/core/image/fi_adaptor.hh
--- mln/core/image/fi_adaptor.hh (revision 2190)
+++ mln/core/image/fi_adaptor.hh (working copy)
@@ -129,7 +129,8 @@
*/
template <typename I>
- struct fi_adaptor : public internal::image_primary< box2d, fi_adaptor<I> >
+ struct fi_adaptor : public internal::image_primary< mln_value(I), box2d,
+ fi_adaptor<I> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box2d pset;
Index: mln/core/image/image3d.hh
--- mln/core/image/image3d.hh (revision 2190)
+++ mln/core/image/image3d.hh (working copy)
@@ -113,7 +113,7 @@
* thickness around data.
*/
template <typename T>
- struct image3d : public internal::image_primary< box3d, image3d<T> >
+ struct image3d : public internal::image_primary< T, box3d, image3d<T> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box3d pset;
Index: mln/core/image/complex_image.hh
--- mln/core/image/complex_image.hh (revision 2190)
+++ mln/core/image/complex_image.hh (working copy)
@@ -100,7 +100,7 @@
/// Values are stored on the vertices of the graph.
template <unsigned D, typename P, typename V>
struct complex_image :
- public internal::image_primary_< p_complex<D, P>, complex_image<D, P, V> >
+ public internal::image_primary_< V, p_complex<D, P>, complex_image<D,P,V> >
{
/// Super type.
typedef mln::internal::image_base_< p_complex<D, P>,
Index: mln/core/image/inplace.hh
Index: mln/core/image/extension_val.hh
--- mln/core/image/extension_val.hh (revision 2190)
+++ mln/core/image/extension_val.hh (working copy)
@@ -87,7 +87,8 @@
// FIXME: Doc!
template <typename I>
- class extension_val : public internal::image_identity< I, mln_pset(I), extension_val<I> >
+ class extension_val :
+ public internal::image_identity< I, mln_pset(I), extension_val<I> >
{
public:
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 2190)
+++ mln/core/internal/image_base.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/internal/data.hh>
# include <mln/core/internal/morpher_lvalue.hh>
# include <mln/util/tracked_ptr.hh>
-
+# include <mln/value/set.hh>
// image_base
// ^
@@ -72,9 +72,10 @@
- /// \internal A base class for images. Parameter \p S is the
- /// image site set type.
- template <typename S, typename E>
+ /// \internal A base class for images.
+ /// Parameter \p S is the image site set type.
+ /// Parameter \p V is the image value type.
+ template <typename T, typename S, typename E>
struct image_base
:
public image_checked_<E>
@@ -101,6 +102,9 @@
/// fwd_piter.
typedef fwd_piter piter;
+ /// associated type.
+ typedef mln::value::set<T> t_eligible_value_set;
+
/// Test if \p p belongs to the image domain.
bool has(const psite& p) const;
@@ -113,6 +117,8 @@
// FIXME: Add void init_data(..);
+ // Return the set of the image eligigle values
+ const t_eligible_value_set& values_eligible() const;
/// Assignment operator.
image_base& operator=(const image_base& rhs);
@@ -138,25 +144,25 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
- image_base<S,E>::image_base()
+ image_base<T, S, E>::image_base()
{
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
- image_base<S,E>::image_base(const image_base& rhs)
+ image_base<T, S, E>::image_base(const image_base& rhs)
: image_checked_<E>()
{
mln_precondition(exact(rhs).has_data()); // FIXME: Is-it too restrictive?
this->data_ = rhs.data_;
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
- image_base<S,E>&
- image_base<S,E>::operator=(const image_base<S,E>& rhs)
+ image_base<T, S, E>&
+ image_base<T, S, E>::operator=(const image_base<T, S, E>& rhs)
{
mln_precondition(exact(rhs).has_data()); // FIXME: Is-it too restrictive?
if (& rhs == this) // || ! exact(rhs).has_data())
@@ -165,27 +171,27 @@
return *this;
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
bool
- image_base<S,E>::has_data() const
+ image_base<T, S, E>::has_data() const
{
return data_ != 0;
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
bool
- image_base<S,E>::has(const psite& p) const
+ image_base<T, S, E>::has(const psite& p) const
{
mln_precondition(exact(this)->has_data());
return exact(this)->domain().has(p);
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
std::size_t
- image_base<S,E>::nsites() const
+ image_base<T, S, E>::nsites() const
{
mlc_equal(mln_trait_site_set_nsites(S),
mln::trait::site_set::nsites::known)::check();
@@ -193,10 +199,18 @@
return exact(this)->domain().nsites();
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
+ inline
+ const typename image_base<T, S, E>::t_eligible_value_set&
+ image_base<T, S, E>::values_eligible() const
+ {
+ return t_eligible_value_set::the();
+ }
+
+ template <typename T, typename S, typename E>
inline
void
- image_base<S,E>::destroy()
+ image_base<T, S, E>::destroy()
{
data_.clean_();
}
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 2190)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -48,8 +48,8 @@
* \c I is the underlying-morphed image type.
*
*/
- template <typename I, typename S, typename E>
- class image_morpher : public image_base<S, E>
+ template <typename I, typename T, typename S, typename E>
+ class image_morpher : public image_base<T, S, E>
{
public:
@@ -106,40 +106,40 @@
namespace internal
{
- template <typename I, typename S, typename E>
+ template <typename I, typename T, typename S, typename E>
inline
- image_morpher<I,S,E>::image_morpher()
+ image_morpher<I, T, S, E>::image_morpher()
{
}
- template <typename I, typename S, typename E>
+ template <typename I, typename T, typename S, typename E>
inline
mlc_const(I)*
- image_morpher<I,S,E>::delegatee_() const
+ image_morpher<I, T, S, E>::delegatee_() const
{
return this->data_ == 0 ? 0 : & this->data_->ima_;
}
- template <typename I, typename S, typename E>
+ template <typename I, typename T, typename S, typename E>
inline
I*
- image_morpher<I,S,E>::delegatee_()
+ image_morpher<I, T, S, E>::delegatee_()
{
return this->data_ == 0 ? 0 : & this->data_->ima_;
}
- template <typename I, typename S, typename E>
+ template <typename I, typename T, typename S, typename E>
inline
- image_morpher<I,S,E>::operator I() const
+ image_morpher<I, T, S, E>::operator I() const
{
mln_precondition(exact(this)->has_data());
return * this->delegatee_();
}
- template <typename I, typename S, typename E>
+ template <typename I, typename T, typename S, typename E>
inline
bool
- image_morpher<I,S,E>::has_data() const
+ image_morpher<I, T, S, E>::has_data() const
{
return
this->data_ != 0 &&
Index: mln/core/internal/site_set_iterator_base.hh
Index: mln/core/internal/image_primary.hh
--- mln/core/internal/image_primary.hh (revision 2190)
+++ mln/core/internal/image_primary.hh (working copy)
@@ -46,8 +46,8 @@
/*! \internal A base class for primary images.
*
*/
- template <typename S, typename E>
- struct image_primary : public image_base<S, E>
+ template <typename T, typename S, typename E>
+ struct image_primary : public image_base<T, S, E>
{
protected:
image_primary();
@@ -56,9 +56,9 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
- image_primary<S,E>::image_primary()
+ image_primary<T, S, E>::image_primary()
{
}
Index: mln/core/internal/image_identity.hh
--- mln/core/internal/image_identity.hh (revision 2190)
+++ mln/core/internal/image_identity.hh (working copy)
@@ -129,7 +129,7 @@
template <typename I, typename S, typename E>
class image_identity
: public image_identity_impl<I, E>,
- public image_morpher<I, S, E>
+ public image_morpher<I, mln_value(I), S, E>
{
public:
Index: mln/core/internal/image_domain_morpher.hh
--- mln/core/internal/image_domain_morpher.hh (revision 2190)
+++ mln/core/internal/image_domain_morpher.hh (working copy)
@@ -48,7 +48,7 @@
*
*/
template <typename I, typename S, typename E>
- class image_domain_morpher : public image_morpher<I, S, E>
+ class image_domain_morpher : public image_morpher<I, mln_value(I), S, E>
{
public:
Index: mln/core/internal/image_value_morpher.hh
--- mln/core/internal/image_value_morpher.hh (revision 2190)
+++ mln/core/internal/image_value_morpher.hh (working copy)
@@ -48,10 +48,10 @@
/*! \internal A base class for image morphers w.r.t. value.
* Parameter \p S is a point set type.
- *
+ * Parameter \p P is a value type.
*/
- template <typename I, typename E>
- class image_value_morpher : public image_morpher<I, mln_pset(I), E>
+ template <typename I, typename T, typename E>
+ class image_value_morpher : public image_morpher<I, T, mln_pset(I), E>
{
public:
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2190)
+++ mln/core/concept/image.hh (working copy)
@@ -111,6 +111,29 @@
# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+ template <typename values_browsing_trait, typename E>
+ struct image_values_interface_check
+ {
+ static void run() { /* No Requirement */}
+ };
+
+ template <typename E>
+ struct image_values_interface_check<
+ mln::trait::image::value_browsing::value_wise,
+ E>
+ {
+ static void run()
+ {
+ void (E::*m)(const typename E::value& old_val,
+ const typename E::value& new_val) = & E::change_value;
+ m = 0;
+ }
+ };
+ }
+
template <typename E>
inline
Image<E>::Image()
@@ -139,6 +162,7 @@
typedef mln_value(E) value;
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
+ typedef typename E::t_eligible_value_set t_eligible_value_set;
typedef mln_vset(E) vset;
const vset& (E::*m5)() const = & E::values;
@@ -152,7 +176,14 @@
const pset& (E::*m8)() const = & E::domain;
m8 = 0;
+ const t_eligible_value_set& (E::*m9)() const = & E::values_eligible;
+ m9 = 0;
+
typedef typename E::skeleton skeleton;
+
+ /// Optional interface:
+ internal::image_values_interface_check<mln_trait_image_value_browsing(E),
+ E>::run();
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/level/fill_with_value.hh
--- mln/level/fill_with_value.hh (revision 2190)
+++ mln/level/fill_with_value.hh (working copy)
@@ -40,6 +40,8 @@
* \toto Activate fill_with_value_cell_wise.
*/
+# include <cstdlib>
+
# include <mln/core/concept/image.hh>
# include <mln/core/image/inplace.hh>
# include <mln/core/image/instant.hh>
@@ -112,6 +114,7 @@
trace::entering("level::impl::fill_with_value_cell_wise");
abort();
+
// mln_viter(I) v(ima.values());
// for_all(v)
// v.change_to(val);
Index: mln/border/find.hh
--- mln/border/find.hh (revision 2190)
+++ mln/border/find.hh (working copy)
@@ -59,16 +59,16 @@
namespace impl
{
- template <typename I, typename S, typename E>
+ template <typename I, typename T, typename S, typename E>
inline
- unsigned find__(const mln::internal::image_morpher<I,S,E>& ima)
+ unsigned find__(const mln::internal::image_morpher<I, T, S, E>& ima)
{
return border::find(*ima.delegatee_());
}
- template <typename S, typename E>
+ template <typename T, typename S, typename E>
inline
- unsigned find__(const mln::internal::image_base<S,E>&)
+ unsigned find__(const mln::internal::image_base<T, S, E>&)
{
return 0;
}
Index: mln/make/box2d.hh
--- mln/make/box2d.hh (revision 2190)
+++ mln/make/box2d.hh (working copy)
@@ -79,7 +79,8 @@
{
mln_precondition(nrows != 0 && ncols != 0);
mln::box2d tmp(make::point2d(0, 0),
- make::point2d(nrows - 1, ncols - 1));
+ make::point2d(nrows - 1,
+ ncols - 1));
return tmp;
}
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 2190)
+++ mln/pw/image.hh (working copy)
@@ -114,7 +114,8 @@
*
*/
template <typename F, typename S>
- struct image : public internal::image_primary< S, image<F,S> >
+ struct image :
+ public internal::image_primary<mln_result(F), S, image<F,S> >
{
/// Skeleton.
typedef image< tag::function_<F>, tag::pset_<S> > skeleton;
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 2190)
+++ mln/algebra/vec.hh (working copy)
@@ -47,6 +47,7 @@
# include <mln/value/ops.hh>
+
// FIXME: Document.
@@ -56,14 +57,16 @@
// Forward declarations.
namespace algebra {
template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> struct h_vec;
+ template <unsigned d, typename C> class h_vec;
}
+
namespace literal {
struct zero_t;
}
+
namespace trait
{
2
1
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add the sub_image_if image type.
* doc/tutorial/examples/sub_image_if.cc: New.
* mln/core/image/sub_image_if.hh: New.
* mln/fun/p2b/has.hh: New.
Misc.
* mln/core/image/translate_image.hh
(lvalue): Use the recent macro.
(operator()): Likewise.
* mln/core/image/t_image.hh: Likewise.
* mln/core/internal/image_base.hh: Fix doc.
Layout; group value-related material.
(hook_data_, id_): Move impl into guards.
* mln/core/internal/image_morpher.hh: Add some doc.
* mln/core/internal/image_domain_morpher.hh: Fix doc.
(lvalue): Use the recent macro.
(values): Layout; group value-related material.
doc/tutorial/examples/sub_image_if.cc | 101 ++++++++++++
mln/core/image/sub_image_if.hh | 246 ++++++++++++++++++++++++++++++
mln/core/image/t_image.hh | 8
mln/core/image/translate_image.hh | 8
mln/core/internal/image_base.hh | 49 ++++-
mln/core/internal/image_domain_morpher.hh | 16 +
mln/core/internal/image_morpher.hh | 7
mln/fun/p2b/has.hh | 134 ++++++++++++++++
8 files changed, 543 insertions(+), 26 deletions(-)
Index: doc/tutorial/examples/sub_image_if.cc
--- doc/tutorial/examples/sub_image_if.cc (revision 0)
+++ doc/tutorial/examples/sub_image_if.cc (revision 0)
@@ -0,0 +1,101 @@
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/sub_image_if.hh>
+
+# include <mln/core/image/sub_image.hh>
+# include <mln/core/image/image_if.hh>
+
+# include <mln/pw/all.hh>
+# include <mln/core/var.hh>
+
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/labeling/blobs.hh>
+# include <mln/geom/bbox.hh>
+
+# include <mln/level/fill.hh>
+# include <mln/debug/println.hh>
+
+
+template <typename I>
+void foo(const I& input)
+{
+ using namespace mln;
+
+ std::cout << std::endl << "foo!" << std::endl << std::endl;
+
+ typedef mln_ch_value(I, float) O;
+
+// p_if< box2d,
+// fun::p2b::has< image_if< image2d<float>, F> >
+// >
+
+// p_if< box2d,
+// fun::p2b::has< image_if< image2d_int_u8, F > >
+// >
+
+
+
+ // type of " mln_ch_value(I, float) "
+
+// sub_image_if< I = image_if< image2d<float>, F >
+// S = box2d >
+//
+// where:
+//
+// F = fun::neq_p2b_expr_< pw::value_< image2d<value::int_u<8u> > >,
+// pw::cst_<unsigned int> >
+// >,
+
+ O output;
+ initialize(output, input);
+ level::fill(output, 9);
+
+ std::cout << geom::bbox(output) << std::endl;
+ debug::println(output);
+}
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ bool vals[6][5] = {
+ {0, 1, 1, 0, 0},
+ {0, 1, 1, 0, 0},
+ {0, 0, 0, 0, 0},
+ {1, 1, 0, 1, 0},
+ {1, 0, 1, 1, 1},
+ {1, 0, 0, 0, 0}
+ };
+ image2d<bool> ima = make::image2d(vals);
+ debug::println(ima);
+
+ int_u8 nlabels;
+ image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels);
+ debug::println(lab);
+
+ mln_VAR(lab_0, lab | (pw::value(lab) != pw::cst(0u)));
+ debug::println(lab_0);
+
+// box2d b = geom::bbox(lab | (pw::value(lab) == pw::cst(3u)));
+// std::cout << b << std::endl;
+
+
+// {
+// mln_VAR(temp, lab | (pw::value(lab) == pw::cst(3u)));
+// std::cout << temp.un_if().bbox() << std::endl;
+// debug::println(temp);
+// std::cout << geom::bbox(lab | (pw::value(lab) == pw::cst(3u))) << std::endl;
+
+// foo(temp);
+// }
+
+ box2d bb = make::box2d(2,1, 5,4);
+ debug::println(lab / bb);
+
+ mln_VAR(lab_3, lab_0 / bb);
+ debug::println(lab_3);
+
+ foo(lab_3);
+}
Index: mln/core/image/translate_image.hh
--- mln/core/image/translate_image.hh (revision 2193)
+++ mln/core/image/translate_image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -105,7 +105,7 @@
typedef line_piter_<mln_psite(I)> line_piter;
/// Return type of read-write access.
- typedef typename internal::morpher_lvalue_<I>::ret lvalue;
+ typedef mln_morpher_lvalue(I) lvalue;
/// Skeleton.
typedef translate_image< tag::image_<I> > skeleton;
@@ -127,7 +127,7 @@
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
/// Read and "write if possible" access of pixel value at point site \p p.
- lvalue operator()(const mln_psite(I)& p);
+ mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
};
@@ -192,7 +192,7 @@
template <typename I>
inline
- typename translate_image<I>::lvalue
+ mln_morpher_lvalue(I)
translate_image<I>::operator()(const mln_psite(I)& p)
{
mln_assertion(this->has(p));
Index: mln/core/image/t_image.hh
--- mln/core/image/t_image.hh (revision 2193)
+++ mln/core/image/t_image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -95,7 +95,7 @@
typedef mln_value(I) value;
/// Type returned by the read-write pixel value operator.
- typedef typename internal::morpher_lvalue_<I>::ret lvalue;
+ typedef mln_morpher_lvalue(I) lvalue;
/// Return type of read-only access.
typedef mln_rvalue(I) rvalue;
@@ -136,7 +136,7 @@
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
/// Read-write access of pixel value at point site \p p.
- lvalue operator()(const mln_psite(I)& p);
+ mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
/// Give the set of values of the image.
const vset& values() const;
@@ -257,7 +257,7 @@
template <typename I>
inline
- typename internal::morpher_lvalue_<I>::ret
+ mln_morpher_lvalue(I)
t_image<I>::operator()(const mln_psite(I)& p)
{
mln_precondition(this->has(p));
Index: mln/core/image/sub_image_if.hh
--- mln/core/image/sub_image_if.hh (revision 0)
+++ mln/core/image/sub_image_if.hh (revision 0)
@@ -0,0 +1,246 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_SUB_IMAGE_IF_HH
+# define MLN_CORE_IMAGE_SUB_IMAGE_IF_HH
+
+/*!
+ * \file mln/core/image/sub_image_if.hh
+ *
+ * \brief FIXME DOC!
+ *
+ * \todo Activate preconditions.
+ */
+
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/site_set/p_if.hh>
+# include <mln/fun/p2b/has.hh>
+
+# include <mln/debug/println.hh>
+
+
+namespace mln
+{
+
+
+ // Forward declaration.
+ template <typename I, typename S> class sub_image_if;
+
+
+ namespace internal
+ {
+
+ /// \internal Data structure for \c mln::sub_image_if<I,S>.
+ template <typename I, typename S>
+ struct data< sub_image_if<I,S> >
+ {
+ data(I& ima, const S& s);
+
+ I ima_;
+ p_if< S, fun::p2b::has<I> > s_;
+ };
+
+ } // end of namespace mln::internal
+
+
+
+ namespace trait
+ {
+
+ template <typename I, typename S>
+ struct image_< sub_image_if<I,S> > : default_image_morpher< I,
+ mln_value(I),
+ sub_image_if<I,S> >
+ {
+// private:
+// typedef mln_trait_image_data(I) I_data_;
+// typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
+// public:
+
+ typedef trait::image::category::domain_morpher category;
+
+ typedef trait::image::ext_domain::none ext_domain; // No extension of domain.
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
+
+ typedef trait::image::value_storage::disrupted value_storage;
+ // HOT FIXME: except if S is a Box
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ template <typename I, typename S>
+ struct sub_image_if : public internal::image_domain_morpher< I,
+ p_if< S, fun::p2b::has<I> >,
+ sub_image_if<I,S> >
+ {
+ /// Skeleton.
+ typedef sub_image_if< tag::image_<I>, tag::pset_<S> > skeleton;
+
+ /// Constructor without argument.
+ sub_image_if();
+
+ /// Constructor.
+ sub_image_if(I& ima, const S& s);
+
+ /// Initialization.
+ void init_(I& ima, const S& s);
+
+ /// Give the definition domain.
+ const p_if< S, fun::p2b::has<I> >& domain() const;
+
+// /// Const promotion via conversion.
+// operator sub_image_if<const I, S>() const;
+ };
+
+
+
+
+
+ template <typename I, typename S>
+ sub_image_if<const I, S>
+ operator / (const Image<I>& ima, const Site_Set<S>& s);
+
+
+ template <typename I, typename S>
+ sub_image_if<I, S>
+ operator / (Image<I>& ima, const Site_Set<S>& s);
+
+
+ template <typename I, typename S, typename J>
+ void init_(tag::image_t, sub_image_if<I,S>& target, const J& model);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // init_
+
+ template <typename I, typename S, typename J>
+ inline
+ void init_(tag::image_t, sub_image_if<I,S>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, model);
+ S s;
+ init_(tag::domain, s, model);
+ target.init_(ima, s);
+ }
+
+
+ // internal::data< sub_image_if<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename S>
+ inline
+ data< sub_image_if<I,S> >::data(I& ima, const S& s)
+ : ima_(ima)
+ {
+ typedef fun::p2b::has<I> F;
+ F f(ima);
+ s_ = p_if<S,F>(s, f);
+ }
+
+ } // end of namespace mln::internal
+
+
+ // sub_image_if<I,S>
+
+ template <typename I, typename S>
+ inline
+ sub_image_if<I,S>::sub_image_if()
+ {
+ }
+
+ template <typename I, typename S>
+ inline
+ sub_image_if<I,S>::sub_image_if(I& ima, const S& s)
+ {
+ init_(ima, s);
+ }
+
+ template <typename I, typename S>
+ inline
+ void
+ sub_image_if<I,S>::init_(I& ima, const S& s)
+ {
+ mln_precondition(! this->has_data());
+ this->data_ = new internal::data< sub_image_if<I,S> >(ima, s);
+ }
+
+ template <typename I, typename S>
+ inline
+ const p_if< S, fun::p2b::has<I> >&
+ sub_image_if<I,S>::domain() const
+ {
+ return this->data_->s_;
+ }
+
+// template <typename I, typename S>
+// inline
+// sub_image_if<I,S>::operator sub_image_if<const I, S>() const
+// {
+// sub_image_if<const I, S> tmp(this->data_->ima_,
+// this->data_->s_);
+// return tmp;
+// }
+
+
+ // Operators.
+
+ template <typename I, typename S>
+ inline
+ sub_image_if<const I, S>
+ operator / (const Image<I>& ima, const Site_Set<S>& s)
+ {
+ // FIXME: mln_precondition(set::inter(ima.domain(), s) != 0);
+ sub_image_if<const I, S> tmp(exact(ima), exact(s));
+ return tmp;
+ }
+
+ template <typename I, typename S>
+ inline
+ sub_image_if<I, S>
+ operator / (Image<I>& ima, const Site_Set<S>& s)
+ {
+ // FIXME: mln_precondition(set::inter(ima.domain(), s) != 0);
+ sub_image_if<I, S> tmp(exact(ima), exact(s));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_SUB_IMAGE_IF_HH
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 2193)
+++ mln/core/internal/image_base.hh (working copy)
@@ -73,14 +73,24 @@
/// \internal A base class for images.
+ /// Parameter \p T is the image value type.
/// Parameter \p S is the image site set type.
- /// Parameter \p V is the image value type.
template <typename T, typename S, typename E>
struct image_base
:
public image_checked_<E>
{
+ /// Value associated type.
+ typedef T value;
+
+ /// Eligible-value-set associated type.
+ typedef mln::value::set<T> t_eligible_value_set;
+
+ // Return the set of the image eligigle values
+ const t_eligible_value_set& values_eligible() const;
+
+
/// Site_Set associated type.
typedef S pset;
@@ -102,8 +112,6 @@
/// fwd_piter.
typedef fwd_piter piter;
- /// associated type.
- typedef mln::value::set<T> t_eligible_value_set;
/// Test if \p p belongs to the image domain.
@@ -117,23 +125,28 @@
// FIXME: Add void init_data(..);
- // Return the set of the image eligigle values
- const t_eligible_value_set& values_eligible() const;
- /// Assignment operator.
+ /// Assignment operator (performs a shallow assignment).
image_base& operator=(const image_base& rhs);
- /// Copy constructor.
+ /// Copy constructor (performs a shallow copy).
image_base(const image_base& rhs);
+ /// Give an identifier of this image. When several image
+ /// variables designate the same image, they share the same
+ /// identifier.
+ const void* id_() const;
+
+
/// Detach data from an image (free it if nobody else hold it).
void destroy();
- const util::tracked_ptr< internal::data<E> >& hook_data_() const { return data_; }
-
- const void* id_() const { return data_.ptr_; }
+ /// Hook to the image data.
+ const util::tracked_ptr< internal::data<E> >& hook_data_() const;
protected:
+
+ /// Constructor without argument.
image_base();
// Internal data, sharable by several images.
@@ -173,6 +186,14 @@
template <typename T, typename S, typename E>
inline
+ const void*
+ image_base<T, S, E>::id_() const
+ {
+ return data_.ptr_;
+ }
+
+ template <typename T, typename S, typename E>
+ inline
bool
image_base<T, S, E>::has_data() const
{
@@ -215,6 +236,14 @@
data_.clean_();
}
+ template <typename T, typename S, typename E>
+ inline
+ const util::tracked_ptr< internal::data<E> >&
+ image_base<T, S, E>::hook_data_() const
+ {
+ return data_;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::internal
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 2193)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -46,13 +46,13 @@
/*! \internal A base class for images that are morphers. Parameter
* \c I is the underlying-morphed image type.
- *
*/
template <typename I, typename T, typename S, typename E>
class image_morpher : public image_base<T, S, E>
{
public:
+ /// Delegatee associated type.
typedef I delegatee;
/// Return the delegatee_ pointer; default code.
@@ -64,7 +64,8 @@
/* \brief Test if this image has been initialized; default impl.
*
* This default impl is stronger than the one inherited from
- * image_base.
+ * image_base because it also tests that the morphed image is
+ * also initialized.
*/
bool has_data() const;
Index: mln/core/internal/image_domain_morpher.hh
--- mln/core/internal/image_domain_morpher.hh (revision 2193)
+++ mln/core/internal/image_domain_morpher.hh (working copy)
@@ -44,7 +44,10 @@
/*! \internal A base class for image morphers w.r.t. domain.
- * Parameter \p S is a point set type.
+ *
+ * Parameter \p I is the morphed image type.
+ * Parameter \p S is the morpher site set type.
+ * Parameter \p E is the exact (morpher image) type.
*
*/
template <typename I, typename S, typename E>
@@ -55,6 +58,10 @@
/// Value_Set associated type.
typedef mln_vset(I) vset;
+ /// Give the set of values.
+ const vset& values() const;
+
+
/// Value associated type.
typedef mln_value(I) value;
@@ -62,12 +69,9 @@
typedef mln_rvalue(I) rvalue;
/// Return type of read-write access.
- typedef typename internal::morpher_lvalue_<I>::ret lvalue;
+ typedef mln_morpher_lvalue(I) lvalue;
- /// Give the set of values.
- const vset& values() const;
-
/// Read-only access of pixel value at point site \p p.
rvalue operator()(const mln_psite(S)& p) const;
@@ -75,6 +79,8 @@
lvalue operator()(const mln_psite(S)& p);
protected:
+
+ /// Constructor (protected) without argument.
image_domain_morpher();
};
Index: mln/fun/p2b/has.hh
--- mln/fun/p2b/has.hh (revision 0)
+++ mln/fun/p2b/has.hh (revision 0)
@@ -0,0 +1,134 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_FUN_P2B_HAS_HH
+# define MLN_FUN_P2B_HAS_HH
+
+/*! \file mln/fun/p2b/has.hh
+ *
+ * \brief Function "psite-> bool" that maps the call "ima.has(p)".
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/metal/const.hh>
+# include <mln/metal/unconst.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ // FIXME: Doc!
+
+ template <typename I>
+ struct has : public Function_p2b< has<I> >
+ {
+ /// Result associated type.
+ typedef bool result;
+
+ /// Apply the function on the psite \p p.
+ bool operator()(const mln_psite(I)& p) const;
+
+
+ /// Constructor without argument.
+ has();
+
+ /// Constructor from an image \p ima.
+ has(mlc_const(I)& ima);
+
+
+ /// Copy constructor.
+ has(const has<I>& rhs);
+
+ /// Assignment operator.
+ has<I>& operator=(const has<I>& rhs);
+
+ private:
+ mlc_const(I) ima_;
+ typedef Function_p2b< has<I> > super_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ bool
+ has<I>::operator()(const mln_psite(I)& p) const
+ {
+ return ima_.has(p);
+ }
+
+ template <typename I>
+ inline
+ has<I>::has()
+ : ima_()
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>::has(mlc_const(I)& ima)
+ : ima_(ima)
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>::has(const has<I>& rhs)
+ : Function_v2v< has<I> >(), // Please g++.
+ super_(),
+ ima_(rhs.ima_)
+ {
+ }
+
+ template <typename I>
+ inline
+ has<I>&
+ has<I>::operator=(const has<I>& rhs)
+ {
+ if (&rhs == this)
+ return *this;
+ const_cast<mlc_unconst(I)&>(this->ima_) = rhs.ima_;
+ return *this;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_HAS_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln
Git branch: cleanup (HEAD: 557f721)
ChangeLog:
2008-09-08 Guillaume Lazzara <z(a)lrde.epita.fr>
First draft of the tutorial.
* milena/doc/tutorial/tutorial.tex: New.
---
ChangeLog | 5 +
milena/doc/tutorial/tutorial.tex | 578 ++++++++++++++++++++++++++++++++++++++
2 files changed, 583 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fb00fa6..c2d0668 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ First draft of the tutorial.
+ * milena/doc/tutorial/tutorial.tex: New.
+
2008-05-05 Roland Levillain <roland(a)lrde.epita.fr>
Update the list of Makefiles to be configured.
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
new file mode 100644
index 0000000..1df6993
--- /dev/null
+++ b/milena/doc/tutorial/tutorial.tex
@@ -0,0 +1,578 @@
+\documentclass{report}
+\usepackage{graphicx}
+\usepackage{listings}
+\usepackage{makeidx}
+\usepackage{xcolor}
+
+\newcommand{\img}[4]{
+\begin{figure}[ht!]
+ \begin{center}
+ \includegraphics[width=#2]{figures/#1}
+ \caption{#4\label{fig:#1}}
+ \end{center}
+ \end{figure}
+}
+
+\title{Olena - Tutorial
+}
+\author{LRDE}
+\date{}
+
+%%%LISTINGS SETTINGS
+\lstset{frameround=fttt}
+\lstloadlanguages{[ISO]C++}
+\lstset{backgroundcolor=\color{yellow}}
+
+
+\begin{document}
+
+\tableofcontents
+
+ajouter dans => milena/doc/tutorial |
+-------------------------------------------------
+
+\chapter{Foreword}
+
+The following tutorial talks about 2D images. We chose that kind of images
+because it is easier to understand and this is the
+most used. \\
+
+FIXME
+[dessin de grille 2d, colonnes/lignes numerotees + repere x/y]
+Intersection <=> point 2d <=> milieu d'un pixel \\
+
+Since examples are based on 2D images pixels are actually "points" however we
+will call them "sites" which is the most generic name.\\
+
+Here is also a list of common variable name conventions:
+\begin{figure}[ht!]
+ \begin{tabular}{|l|l|}
+ \hline
+ \textbf{Object} & \textbf{Variable name} \\ \hline
+ Site & p \\ \hline
+ Value & v \\ \hline
+ Neighboor & n \\ \hline
+ A site close to another site p & q \\ \hline
+ \end{tabular}
+\end{figure}
+
+Methods provided by the objects in the library are in constant time. If you need
+a specific method but you cannot find it, you may find an algorithm which can
+compute the information you need.
+
+\chapter{Concepts}
+//FIXME lister \underline{TOUS} les concepts (core/concepts)
+
+\section{Site set}
+
+Site sets are used:
+\begin{enumerate}
+ \item To define an image definition domain.
+ \item As Site container.
+\end{enumerate}
+
+Here is a list of all the site set concepts which can be found in
+core/site\_set:
+
+\begin{tabular}{|l|p{8cm}|}
+\hline
+Site set & Description \\ \hline
+
+p\_complex\_piter & \\ \hline
+p\_graph\_piter & \\ \hline
+p\_key & \\ \hline
+p\_priority & \\ \hline
+p\_run\_piter & \\ \hline
+box & \\ \hline
+p\_bgraph & \\ \hline
+p\_double & \\ \hline
+p\_if & \\ \hline
+p\_line\_graph & \\ \hline
+p\_queue\_fast & \\ \hline
+p\_set & \\ \hline
+box\_piter & \\ \hline
+p\_bgraph\_piter & \\ \hline
+p\_faces & \\ \hline
+p\_if\_piter & \\ \hline
+p\_line\_graph\_piter & \\ \hline
+p\_queue & \\ \hline
+p\_set\_of & \\ \hline
+line2d & \\ \hline
+p\_complex & \\ \hline
+p\_graph & \\ \hline
+p\_image & \\ \hline
+p\_mutable\_array\_of & \\ \hline
+p\_run & \\ \hline
+p\_vaccess & \\ \hline
+\end{tabular}
+
+\subsection{Basic interface}
+Common basic interface:\\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Commor type automatically from the
+given container type
+passed as parameter. These macros can be used with any container like images or
+site sets.ents \\ \hline
+
+bool & is\_valid & - & X & Returns true if it has been initialized. The
+default constructor does not do it. \\ \hline
+
+bool & has & const P\& p & X & See \ref{fig:box_has} \\ \hline
+\end{tabular} \\
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d<int> b(2,3);
+
+ std::cout << b.has(point2d(4, 5)) << std::endl; // false
+ std::cout << b.has(point2d(1, 0)) << std::endl; // true
+ \end{lstlisting}
+ \caption{How to use has()\label{fig:box_has}}
+\end{figure}
+
+
+\subsection{Optional interface}
+Site sets may have other methods depending on their type: \\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Comments \\ \hline
+
+size\_t & nsites & - & - & \\ \hline
+const Box\& & bbox & - & X & Bounding box. Available only on grid site sets.
+\\ \hline
+\end{tabular} \\
+
+The previous methods are available depending on the site set. A box
+will have the bbox() method since it can be retrived in constant time: a box
+is it's own bounding box (see \ref{fig:box_bbox}). A p\_array does not have this
+method since sites do not have to be adjacent. Maintaining such information, in
+order to keep getting the bbox in constant time, would be time and memory
+consuming. Instead of providing a method directly in p\_array, an algorithm is
+available if this information needed (see \ref{fig:parray_bbox}).
+P\_array and box both have a nsites method since the internal structure allow a
+constant time retrieval.
+
+\subsubsection*{Sample code}
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ p_array<point2d> arr;
+
+ // The bbox is computed thanks to bbox() algorithm.
+ box2d<int> box = geom::bbox(arr);
+ std::cout << box << std::endl;
+
+ // p_array provides nsites(),
+ // it can be retrieved in constant time.
+ std::cout << "nsites = " << arr.nsites() << std::endl;
+ \end{lstlisting}
+ \caption{How to retrieve information from a p\_array.\label{fig:parray_bbox}}
+\end{figure}
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d<int> b(2,3);
+
+ // The bbox can be retrived in constant time.
+ std::cout << b.bbox() << std::endl;
+
+ // nsites can be retrieved in constant time.
+ std::cout << "nsites = " << b.nsites() << std::endl;
+ \end{lstlisting}
+ \caption{How to retrieve information from a box.\label{fig:box_bbox}}
+\end{figure}
+
+\clearpage
+\newpage
+\section{Image}
+
+An image is composed both of:
+\begin{itemize}
+\item A function $$
+f : \left\{
+ \begin{array}{lll}
+ Site &\rightarrow & Value \\
+ p & \mapsto & v
+ \end{array}
+\right.
+$$
+\item A site set, also called the "domain".
+\end{itemize}
+
+Every image type is defined on a specific site type. An image2d will always
+have a domain defined by a box2d.
+The Value set, which includes all the possible values a site can have, is also
+called "destination" set.
+
+//FIXME: remove this line
+ici, site <=> Point2d
+
+//FIXME : un tuto existe deja
+[sample code]
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d b(2,3);
+ image2d<int> ima(b); // Define the domain of the image.
+
+ cout << b << std::endl; // Display b
+
+ cout << ima.domain() << std::endl; // Display b too
+ \end{lstlisting}
+ \caption{Equivalence between domain and bounding box.\label{fig:img_bbox}}
+\end{figure}
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d b(2,3);
+ image2d<int> ima(b);
+ point2d p(1, 2);
+
+ ima.at(1,2) = 9; // The value is returned by reference
+ // and can be changed.
+ cout << ima(p) << std::endl; // prints 9
+
+ ima(p) = 2; // The value is returned by reference
+ // and can be changed.
+ cout << ima(p) << std::endl; // prints 2
+ \end{lstlisting}
+ \caption{How to update a site value.\label{fig:img_sitevalue}}
+\end{figure}
+
+
+\subsection{Interface}
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Comments \\ \hline
+
+site\_set & domain & - & X - & \\ \hline
+const Value\& & operator() & const point\& p & X & Used for reading. \\ \hline
+Value\& & operator() & const point\& p & - & Used for writing. \\ \hline
+const P\& & at & unsigned x,
+ unsigned y & X & Used for reading. \\ \hline
+P\& & at & unsigned x,
+ unsigned y & - & Used for writing. \\ \hline
+bool & has & const Point\& p & X & \\ \hline
+bool & has\_data & - & X & Returns true if the domain is defined. \\ \hline
+site\_id & id & - & X & Return the Id of the underlying shared data. \\ \hline
+FIXME & destination & - & X & Value set of all the possible site values in this
+Image. \\ \hline
+
+\end{tabular}
+
+Images do not actually store the data in the class. This is a pointer
+to an allocated space which can be shared with other objects. Once an image is
+assigned to another one, the two images share the same data so they have the
+same ID and point to the same memory space.
+If a deep copy of the image is needed, a method clone() is available.
+Example in figure \ref{fig:img_sitevalue} illustrates this behavior.
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ image2d<int> ima1(box2d(2, 3));
+ image2d<int> ima2;
+ image2d<int> ima3;
+ point2d p(1,2);
+
+ ima2 = ima1; // ima1.id() == ima2.id()
+ // and both point to the same memory area.
+
+ ima2(p) = 2; // ima1 is modified as well.
+
+ // prints "2 - 2"
+ std::cout << ima2(p) << " - " << ima1(p) << std::endl;
+ // prints "true"
+ std::cout << (ima2.id() == ima1.id()) << std::endl;
+
+ ima3 = ima1.clone(); // Makes a deep copy.
+
+ ima3(p) = 3;
+
+ // prints "3 - 2"
+ std::cout << ima3(p) << " - " << ima1(p) << std::endl;
+ // prints "false"
+ std::cout << (ima3.id() == ima1.id()) << std::endl;
+ \end{lstlisting}
+ \caption{Data sharing with Images.\label{fig:img_sitevalue}}
+\end{figure}
+
+[Illustration : grille + intersection + pmin() + pmax() + distance entre 2
+points en x et en y = 1]\\
+
+\newpage
+\section{Neighborhood}
+
+
+
+\newpage
+\section{Window}
+
+
+
+\newpage
+\section{Accumulator}
+\section{Box}
+\section{Browsing}
+\section{Delta point site}
+\section{Dpoint}
+\section{Function}
+\section{Gdpoint}
+\section{Generalized pixel}
+\section{Gpoint}
+
+\section{Iterator}
+\section{Literal}
+\section{Mesh}
+\section{Meta accumulator}
+\section{Object}
+\section{Pixel iterator}
+\section{Point}
+\section{Point site}
+\section{Proxy}
+\section{Pseudo site}
+\section{Regular grid}
+\section{Site}
+\section{Site iterator}
+\section{Site proxy}
+\section{Value}
+\section{Value iterator}
+\section{Value set}
+\section{Weighted window}
+
+\chapter{Iterators}
+
+Every objects
+Each container object in Olena like site sets or images have iterators.
+There are usually three kinds:
+\begin{itemize}
+\item \textbf{fwd\_iter}, depends on the container,
+\item \textbf{bkd\_iter}, iterates like forward but to the opposite way,
+\item \textbf{iter}, usually the same as fwd\_iter. It is guaranteed to
+iterate all over the elements.
+\end{itemize}
+
+The iterator type name depends on the data pointed by it: \\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Data type & Iterator Names \\ \hline
+Site & fwd\_piter, bkd\_piter, piter \\ \hline
+Value & fwd\_viter, bkd\_viter, viter \\ \hline
+\end{tabular} \\
+
+As you may have noticed, according to the data type, the word "iter" is prefixed
+by the usual name variable used for that data type. Sites variables are usually
+called 'p' so the proper iterator is "piter".\\
+
+
+An iterator has the following interface: \\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Comments \\ \hline
+
+void & start & - & - & \\ \hline
+void & next & - & - & \\ \hline
+bool & is\_valid & - & - & Return false if created with the default
+constructor and not associated to a proper container.\\ \hline
+\end{tabular} \\
+
+
+Example of different forward iterations:
+\begin{itemize}
+ \item box2d: from top to bottom then from left to right.
+ \item p\_array<point2d>: from left to right.
+\end{itemize}
+
+A for\_all() macro is available to iterate over all the sites
+(Fig. \ref{fig:for_all}). \\
+
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d b(3, 2);
+ mln_piter(box2d) p(b);
+
+ for_all(p)
+ std::cout << p; //prints every site coordinates.
+ \end{lstlisting}
+ \caption{Use of the for\_all() macro.\label{fig:for_all}}
+\end{figure}
+
+Note that when you declare an iterator, prefer using the "mln\_*iter" macros.
+They resolve the iterator type automatically from the given container type
+passed as parameter. These macros can be used with any container like images or
+site sets.
+(\ref{fig:iter_allcontainers}).
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ image2d<int> ima(box2d<int>(2, 3));
+
+ mln_piter(box2d<int>) p(ima.domain());
+ for_all(p)
+ std::cout << p << std::endl;
+
+ mln_viter(image2d<int>) v(ima.destination());
+ for_all(v)
+ std::cout << v << std::endl;
+ \end{lstlisting}
+ \caption{mln\_*iter macros can be used with any
+containers.\label{fig:iter_allcontainers}}
+\end{figure}
+
+
+\chapter{Basic operations}
+//FIXME : illustrer
+\begin{itemize}
+ \item level::clone(), creates a deep copy of an object. Any shared data is
+duplicated.
+ \item level::fill(), fill an object with a value (fig. \ref{fig:fill_impl}).
+ \item level::paste(), paste object data to another object (fig.
+\ref{fig:paste_impl})
+
+ \item labeling::blobs(), find and label the different components of an image.
+\end{itemize}
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+template <typename I>
+void fill(I& ima, mln_value(I) v)
+{
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = v;
+}
+ \end{lstlisting}
+ \caption{Implementation of the fill routine.\label{fig:fill_impl}}
+\end{figure}
+
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+template <typename I, typename J>
+void paste(const I& data, J& dest)
+{
+ mln_piter(I) p(data.domain());
+ for_all(p)
+ dest(p) = data(p);
+}
+ \end{lstlisting}
+ \caption{Implementation of the paste routine.\label{fig:paste_impl}}
+\end{figure}
+
+
+\section{Work with parts of an image}
+
+Sometime it may be interesting to work only on some part of the image or to
+extract only a sub set of that image. Olena enables that thoughout out the
+operator '|'.
+
+Three kinds of that operator exist:\\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Prototype & Comments \\ \hline
+
+Image $|$ Sub Domain & Create a new image.\\ \hline
+Image $|$ Function\_p2b & Do not create a new image but create a morpher.\\
+\hline
+Function\_p2v $|$ Sub Domain & Do not create a new image but create a morpher.\\
+\hline
+\end{tabular} \\
+
+A Sub Domain can be a site set, an image or any value returned by this
+operator.
+Function\_p2v is a function which returns a Value from a given
+Site and Function\_p2b returns a boolean from a given point. These functions.
+ are actually a sort of predicate. You can easily get of function of
+function\_p2v kind thanks to pw::value(Image). It returns the point to value
+function used in the given image. C functions can also be used as predicate by
+passing the function pointer.
+
+You can easily get a function\_p2b by comparing the value returned
+by a function\_p2v to another Value.
+The following sample code illustrates this feature.
+
+All along the examples, the image "ima" will refer to the following declaration:
+\begin{lstlisting}[frame=single]
+ bool vals[6][5] = {
+ {0, 1, 1, 0, 0},
+ {0, 1, 1, 0, 0},
+ {0, 0, 0, 0, 0},
+ {1, 1, 0, 1, 0},
+ {1, 0, 1, 1, 1},
+ {1, 0, 0, 0, 0}
+ };
+ image2d<bool> ima = make::image2d(vals);
+\end{lstlisting}
+
+A simple example is to fill only a part of an image with a specific value:
+\begin{lstlisting}[frame=single]
+p_array2d<bool> arr;
+
+// We add two points in the array.
+arr.append(point2d(0, 1));
+arr.append(point2d(4, 0));
+
+// We restrict the image to the sites
+// contained in arr and fill these ones
+// with 0.
+// We must call "inplace" here.
+fill(inplace(ima | arr), 0);
+
+
+mln_VAR(ima2, ima | arr);
+// We do not need to call "inplace" here.
+fill(ima2, 0);
+\end{lstlisting}
+
+NOTE: due to C++ issues, "in place" routines, such as fill and paste, which
+modify the image passed as argument, cannot be called directly with temporary
+objects. This means that either the routines are called with an image which is a
+local variable or the image is passed to "inplace()". That routine is a work
+around that \textbf{MUST} be used otherwise the code will not compile. The last
+example show two most common use cases.\\
+
+The two next examples extract a specific component from an image and fill a new
+image with red only in the extracted component's domain.
+\begin{lstlisting}[frame=single]
+ using namespace mln;
+ using value::int_u8;
+ using value::rgb8;
+
+ // Find and label the different components.
+ int_u8 nlabels;
+ image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels);
+
+ // Store a boolean image. True if the site is part of
+ // component 2, false otherwise.
+ mln_VAR(lab_2b, lab | (pw::value(lab) == 2));
+
+ // Get the sub site set containing only the sites
+ // part of component 2.
+ mln_VAR(lab_2, lab_2b.domain(1));
+
+ // Fill the sites of component 2 with red.
+ fill(lab_2, color::red);
+\end{lstlisting}
+
+This last example can be written more quickly:
+\begin{lstlisting}[frame=single]
+ using namespace mln;
+ using value::int_u8;
+ using value::rgb8;
+
+ // Find and label the different components.
+ int_u8 nlabels;
+ image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels);
+
+ // Fill the sites of component 2 with red.
+ fill(inplace(lab.domain(2)), color::red);
+\end{lstlisting}
+
+
+\end{document}
\ No newline at end of file
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix some warnings with g++-4.3.
* mln/core/neighborhood.hh (window): Fix missing namespace.
* mln/core/concept/proxy.hxx: Use mlc_const_return when needed.
* mln/metal/const.hh (mlc_const_return): New macro.
(const_return_): New traits.
core/concept/proxy.hxx | 10 +++++-----
core/neighborhood.hh | 2 +-
metal/const.hh | 19 +++++++++++++++++++
3 files changed, 25 insertions(+), 6 deletions(-)
Index: mln/core/neighborhood.hh
--- mln/core/neighborhood.hh (revision 2192)
+++ mln/core/neighborhood.hh (working copy)
@@ -117,7 +117,7 @@
- typedef window<D> window;
+ typedef mln::window<D> window;
mln::window<D> to_window() const
{
Index: mln/core/concept/proxy.hxx
--- mln/core/concept/proxy.hxx (revision 2192)
+++ mln/core/concept/proxy.hxx (working copy)
@@ -58,7 +58,7 @@
struct helper_unprox_if< true, P >
{
typedef mlc_unqualif(mln_q_subject(P)) ret;
- static mlc_const(mln_q_subject(P)) on(const Proxy<P>& p);
+ static mlc_const_return(mln_q_subject(P)) on(const Proxy<P>& p);
};
template <typename P>
@@ -258,7 +258,7 @@
typedef Subject HOT_actual_subject;
HOT_actual_subject get_subject();
- mlc_const(HOT_actual_subject) get_subject() const;
+ mlc_const_return(HOT_actual_subject) get_subject() const;
};
template <typename Subject, typename E>
@@ -278,7 +278,7 @@
{
return mln::internal::force_exact<E>(*this).subj_();
}
- mlc_const(q_subject) unproxy_() const
+ mlc_const_return(q_subject) unproxy_() const
{
E& self_ = mln::internal::force_exact<E>(*this);
return self_.subj_();
@@ -295,7 +295,7 @@
template <typename P>
inline
- mlc_const(mln_q_subject(P))
+ mlc_const_return(mln_q_subject(P))
helper_unprox_if< true, P >::on(const Proxy<P>& p)
{
return exact(p).unproxy_();
@@ -367,7 +367,7 @@
template <typename Subject, typename E>
inline
- typename mln::metal::const_< typename helper_get_proxy_impl< Subject, E, false >::HOT_actual_subject >::ret
+ typename mln::metal::const_return_< typename helper_get_proxy_impl< Subject, E, false >::HOT_actual_subject >::ret
helper_get_proxy_impl< Subject, E, false >::get_subject() const
{
return unproxy_rec(mln::internal::force_exact<const E>(*this));
Index: mln/metal/const.hh
--- mln/metal/const.hh (revision 2192)
+++ mln/metal/const.hh (working copy)
@@ -37,6 +37,9 @@
# define mlc_const(T) typename mln::metal::const_< T >::ret
+# define mlc_const_return(T) typename mln::metal::const_return_< T >::ret
+
+
namespace mln
{
@@ -44,6 +47,8 @@
namespace metal
{
+ // const_
+
template <typename T> struct const_/* T */ { typedef const T ret; };
template <typename T> struct const_< const T > { typedef const T ret; };
@@ -55,6 +60,20 @@
template <typename T> struct const_< T* const > { typedef const T* const ret; };
template <typename T> struct const_< const T* const > { typedef const T* const ret; };
+
+ // const_return_
+
+ template <typename T> struct const_return_/* T */ { typedef T ret; };
+ template <typename T> struct const_return_< const T > { typedef T ret; };
+
+ template <typename T> struct const_return_< T& > { typedef const T& ret; };
+ template <typename T> struct const_return_< const T& > { typedef const T& ret; };
+
+ template <typename T> struct const_return_< T* > { typedef const T* ret; };
+ template <typename T> struct const_return_< const T* > { typedef const T* ret; };
+ template <typename T> struct const_return_< T* const > { typedef const T* ret; };
+ template <typename T> struct const_return_< const T* const > { typedef const T* ret; };
+
} // end of namespace mln::metal
} // end of namespace mln
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update configure.ac.
* configure.ac: add the new Makefiles present in tests/core/....
configure.ac | 5 +++++
1 file changed, 5 insertions(+)
Index: configure.ac
--- configure.ac (revision 2191)
+++ configure.ac (working copy)
@@ -170,6 +170,11 @@
milena/tests/canvas/morpho/Makefile
milena/tests/convert/Makefile
milena/tests/core/Makefile
+ milena/tests/core/alias/Makefile
+ milena/tests/core/image/Makefile
+ milena/tests/core/other/Makefile
+ milena/tests/core/routine/Makefile
+ milena/tests/core/site_set/Makefile
milena/tests/debug/Makefile
milena/tests/display/Makefile
milena/tests/draw/Makefile
1
0
cleanup-2008 2190: Add convert::to and conversion from v2v; fix misc stuff.
by Thierry Geraud 05 Sep '08
by Thierry Geraud 05 Sep '08
05 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add convert::to and conversion from v2v; fix misc stuff.
* doc/tutorial/examples/vec.cc: New.
* doc/tutorial/examples/box.cc: Augment.
* mln/core/site_set/p_run.hh: Fix missing include.
* mln/value/glf.hh: Fix doc.
* mln/value/concept/all.hh: Fix missing files.
* mln/convert/to.hh: New.
* mln/convert/impl/from_image_to_site_set.hh: Fix typo.
* mln/convert/impl/all.hh: Update.
* mln/convert/impl/from_value_to_value.hh: New.
* mln/convert/from_to.hh (from_to): New overload for
'from' being 'float' and 'int'.
doc/tutorial/examples/box.cc | 6 +
doc/tutorial/examples/vec.cc | 14 +++
mln/convert/from_to.hh | 67 ++++++++++++++++
mln/convert/impl/all.hh | 1
mln/convert/impl/from_image_to_site_set.hh | 2
mln/convert/impl/from_value_to_value.hh | 119 +++++++++++++++++++++++++++++
mln/convert/to.hh | 83 ++++++++++++++++++++
mln/core/site_set/p_run.hh | 1
mln/value/concept/all.hh | 10 +-
mln/value/glf.hh | 4
10 files changed, 299 insertions(+), 8 deletions(-)
Index: doc/tutorial/examples/vec.cc
--- doc/tutorial/examples/vec.cc (revision 0)
+++ doc/tutorial/examples/vec.cc (revision 0)
@@ -0,0 +1,14 @@
+# include <mln/convert/to.hh>
+# include <mln/core/alias/point2d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ algebra::vec<2,float> v;
+ v[0] = 5.14;
+ v[1] = 1.99;
+ std::cout << convert::to<point2d>(v) << std::endl;
+}
Index: doc/tutorial/examples/box.cc
--- doc/tutorial/examples/box.cc (revision 2189)
+++ doc/tutorial/examples/box.cc (working copy)
@@ -25,6 +25,12 @@
{
using namespace mln;
+ {
+ box2d b = make::box2d(2, 3);
+ picture(b);
+ }
+ {
box2d b = make::box2d(1,1, 3,2);
picture(b);
}
+}
Index: mln/core/site_set/p_run.hh
--- mln/core/site_set/p_run.hh (revision 2189)
+++ mln/core/site_set/p_run.hh (working copy)
@@ -36,6 +36,7 @@
*/
# include <mln/core/internal/site_set_base.hh>
+# include <mln/core/site_set/box.hh>
# include <mln/core/internal/pseudo_site_base.hh>
# include <mln/util/index.hh>
Index: mln/value/glf.hh
--- mln/value/glf.hh (revision 2189)
+++ mln/value/glf.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,7 +43,7 @@
{
- /// Alias for 8 bit graylevel.
+ /// Alias for graylevels encoded by float.
typedef graylevel_f glf;
Index: mln/value/concept/all.hh
--- mln/value/concept/all.hh (revision 2189)
+++ mln/value/concept/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,12 +33,14 @@
* \brief File that includes every sub-concept of the Value concept.
*/
-# include <mln/value/concept/integer.hh>
+# include <mln/value/concept/built_in.hh>
+# include <mln/value/concept/data.hh>
# include <mln/value/concept/floating.hh>
-# include <mln/value/concept/vectorial.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/value/concept/scalar.hh>
# include <mln/value/concept/structured.hh>
# include <mln/value/concept/symbolic.hh>
-# include <mln/value/concept/data.hh>
+# include <mln/value/concept/vectorial.hh>
#endif // ! MLN_VALUE_CONCEPT_ALL_HH
Index: mln/convert/to.hh
--- mln/convert/to.hh (revision 0)
+++ mln/convert/to.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_CONVERT_TO_HH
+# define MLN_CONVERT_TO_HH
+
+/*! \file mln/convert/to.hh
+ *
+ * \brief General conversion procedure given the destination type.
+ *
+ * \todo Prefer a static check that fails in the "unknown" case.
+ */
+
+# include <mln/convert/from_to.hh>
+
+
+namespace mln
+{
+
+ namespace convert
+ {
+
+
+ /// Conversion of the object \p from towards an object with type \c T.
+ template <typename T, typename O>
+ inline
+ T
+ to(const O& from);
+
+ // This is no "Object" here to remain as general as possible. For
+ // instance, the conversion "float -> glf" should occur.
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename T, typename O>
+ inline
+ T
+ to(const O& from)
+ {
+ mlc_equal(T, mln_exact(T))::check();
+ trace::entering("convert::to");
+
+ T tmp;
+ impl::from_to_(exact(from), tmp);
+
+ trace::exiting("convert::to");
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_TO_HH
Index: mln/convert/impl/from_image_to_site_set.hh
--- mln/convert/impl/from_image_to_site_set.hh (revision 2189)
+++ mln/convert/impl/from_image_to_site_set.hh (working copy)
@@ -54,7 +54,7 @@
namespace impl
{
- /// Convertion of an image \p from towards a site set \p to.
+ /// Conversion of an image \p from towards a site set \p to.
template <typename I, typename S>
void
from_image_to_site_set(const Image<I>& from, Site_Set<S>& to);
Index: mln/convert/impl/all.hh
--- mln/convert/impl/all.hh (revision 2189)
+++ mln/convert/impl/all.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/convert/impl/from_image_to_site_set.hh>
+# include <mln/convert/impl/from_value_to_value.hh>
#endif // ! MLN_CONVERT_IMPL_ALL_HH
Index: mln/convert/impl/from_value_to_value.hh
--- mln/convert/impl/from_value_to_value.hh (revision 0)
+++ mln/convert/impl/from_value_to_value.hh (revision 0)
@@ -0,0 +1,119 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH
+# define MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH
+
+/*! \file mln/convert/from_to.hh
+ *
+ * \brief General conversion procedure from a value to a value.
+ *
+ * \todo Augment code + add checks.
+ */
+
+# include <utility>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/site_set.hh>
+# include <mln/value/concept/all.hh>
+
+# include <mln/core/site_set/p_run.hh>
+# include <mln/metal/converts_to.hh>
+
+
+
+namespace mln
+{
+
+ namespace convert
+ {
+
+ namespace impl
+ {
+
+ /// Conversion of a value \p from towards a value \p to.
+ template <typename V, typename W>
+ void
+ from_value_to_value(const Value<V>& from, Value<W>& to);
+
+ /// Specialization.
+ template <typename V>
+ void
+ from_value_to_value(const Value<V>& from, Value<V>& to);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Case 1:
+
+ template <typename V, typename W>
+ void
+ from_value_to_value_(const mln::value::Vectorial<V>& from,
+ mln::value::Vectorial<W>& to)
+ {
+ exact(to) = exact(from).to_equiv();
+ }
+
+ // Case 2:
+
+ template <typename V, typename W>
+ void
+ from_value_to_value_(const mln::value::Scalar<V>& from,
+ mln::value::Scalar<W>& to)
+ {
+ exact(to) = exact(from).to_equiv();
+ }
+
+
+ // Facades.
+
+ template <typename V, typename W>
+ inline
+ void
+ from_value_to_value(const Value<V>& from, Value<W>& to)
+ {
+ from_value_to_value_(exact(from), exact(to));
+ }
+
+ template <typename V>
+ inline
+ void
+ from_value_to_value(const Value<V>& from, Value<V>& to)
+ {
+ exact(to) = exact(from);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::convert::impl
+
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH
Index: mln/convert/from_to.hh
--- mln/convert/from_to.hh (revision 2189)
+++ mln/convert/from_to.hh (working copy)
@@ -33,13 +33,21 @@
* \brief General conversion procedure between two objects.
*
* \todo Prefer a static check that fails in the "unknown" case.
+ *
+ * \todo Use 'round' instead of static_cast in vec->Gpoint.
*/
# include <mln/core/concept/object.hh>
+# include <mln/core/concept/gpoint.hh>
+# include <mln/value/concept/all.hh>
+
# include <mln/convert/impl/all.hh>
+
+# include <mln/algebra/vec.hh>
# include <mln/metal/is.hh>
+
namespace mln
{
@@ -47,13 +55,25 @@
{
- /// Convertion of an object \p from towards an object \p to.
+ /// Conversion of an object \p from towards an object \p to.
+
template <typename F, typename T>
inline
void
from_to(const Object<F>& from, Object<T>& to);
+ template <typename T>
+ inline
+ void
+ from_to(const float& from, Object<T>& to);
+
+
+ template <typename T>
+ inline
+ void
+ from_to(const int& from, Object<T>& to);
+
# ifndef MLN_INCLUDE_ONLY
@@ -78,10 +98,34 @@
mln::convert::impl::from_image_to_site_set(from, to);
}
+ // algebra::vec -> Gpoint.
+ template <unsigned n, typename T, typename P>
+ inline
+ void
+ from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_)
+ {
+ mlc_bool(P::dim == n)::check();
+ P& to = exact(to_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< typename P::coord >(from[i]);
+ }
+
+
+ template <typename F, typename T>
+ inline
+ void
+ from_to_(const Value<F>& from, Value<T>& to)
+ {
+ mln::convert::impl::from_value_to_value(from, to);
+ }
} // end of namespace mln::convert::impl
+
+ // Facades.
+
+
template <typename F, typename T>
inline
void
@@ -92,6 +136,27 @@
trace::exiting("convert::from_to");
}
+
+ template <typename T>
+ inline
+ void
+ from_to(const float& from, Object<T>& to)
+ {
+ mlc_is_a(T, mln::value::Floating)::check();
+ exact(to) = from;
+ }
+
+
+ template <typename T>
+ inline
+ void
+ from_to(const int& from, Object<T>& to)
+ {
+ mlc_is_a(T, mln::value::Integer)::check();
+ exact(to) = from;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::convert
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: Update access.hh.
After Theo:
* jardonnet/virtual/access.hh: Concept check, Type sum ...
* jardonnet/virtual/access.cc: Update testes.
access.cc | 2 +-
access.hh | 60 +++++++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 44 insertions(+), 18 deletions(-)
Index: jardonnet/virtual/access.hh
--- jardonnet/virtual/access.hh (revision 2187)
+++ jardonnet/virtual/access.hh (working copy)
@@ -5,6 +5,8 @@
# include <mln/core/image2d.hh>
# include <mln/metal/is.hh>
# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+# include <mln/convert/to.hh>
namespace mln
{
@@ -14,37 +16,48 @@
template < typename I >
struct nearest_neighbor
- : public Function_x2x< nearest_neighbor<I> >
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), nearest_neighbor<I> >::ret
{
typedef mln_value(I) result;
- template < typename V >
+ nearest_neighbor(const I& ima) : ima(ima) {}
+
+ template < unsigned n, typename T >
mln_value(I)
- operator()(const I& img, const V& v) const
+ operator()(const I& img, const algebra::vec<n,T>& x) const
{
- mln_point(I) p = algebra::to_point<mln_point(I)>(v);
+ mln_point(I) p = convert::to<mln_point(I)>(x);
return img(p);
}
+ const I& ima;
};
template < typename I >
struct linear
- : public Function_x2x< linear<I> >
+ : public fun::internal::selector_<const algebra::vec<1,float>,
+ // float is a dummy parameter (real is C)
+ mln_value(I), linear<I> >::ret
{
typedef mln_value(I) result;
+ linear(const I& ima) : ima(ima) {}
+
template <typename C>
mln_value(I)
operator()(const I& img,
const algebra::vec<1,C>& v) const
{
+ typedef mln_sum(mln_value(I)) vsum;
+
// looking for img(x);
double x = v[0];
// p1
double xa = mln_point(I)::coord(v[0]);
- double ya = img(point1d(xa));
+ vsum ya = img(point1d(xa));
// x makes sens in img
if (x == xa)
@@ -52,23 +65,32 @@
// p2
double xb = mln_point(I)::coord(v[0] + 1);
- double yb = img(point1d(xb));
+ vsum yb = img(point1d(xb));
// Taylor-young
- return ya + (x - xa) * (yb - ya) / (xb - xa);
+ return convert::to<mln_value(I)>
+ (ya + (x - xa) * (yb - ya) / (xb - xa));
}
+
+ const I& ima;
};
template < typename I >
struct bilinear
- : public Function_x2x< bilinear<I> >
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), linear<I> >::ret
{
typedef mln_value(I) result;
- template <typename V>
+ bilinear(const I& ima) : ima(ima) {}
+
+ template <unsigned n, typename T>
mln_value(I)
- operator()(const I& img, const V& v) const
+ operator()(const I& img, const algebra::vec<n,T>& v) const
{
+ typedef mln_sum(mln_value(I)) vsum;
+
// q12----r2----q22
// | | |
// | x |
@@ -90,17 +112,20 @@
point2d q22 = point2d(x2, y2);
// linear interpolation #1
- mln_value(I) img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
+ vsum img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
img(q21) * (x - x1) / (x2 - x1);
// linear interpolation #2
- mln_value(I) img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
+ vsum img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
img(q22) * (x - x1) / (x2 - x1);
// interpolating in y direction
- return img_r1 * (y2 - y) / (y2 -y1)
- + img_r2 * (y - y1) /(y2 - y1);
+ return convert::to<mln_value(I)>
+ (img_r1 * (y2 - y) / (y2 -y1)
+ + img_r2 * (y - y1) /(y2 - y1));
}
+
+ const I& ima;
};
}
@@ -112,8 +137,9 @@
access(const I& img, const mln_point(I)& p,
const T& trans, const F& interp)
{
- mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
- mlc_is(F, Function_x2x<F>)::check();
+ mlc_is(typename T::invert,
+ Bijection_x2x<typename T::invert>)::check();
+ mlc_is(F, Function<F>)::check();
return interp(img, (trans.inv())(p));
}
Index: jardonnet/virtual/access.cc
--- jardonnet/virtual/access.cc (revision 2187)
+++ jardonnet/virtual/access.cc (working copy)
@@ -13,7 +13,7 @@
point2d p(5,5);
algebra::vec<2,float> v = make::vec(3,4);
fun::x2x::translation<2,float> t(v);
- interpolation::nearest_neighbor< image2d<int> > nn;
+ interpolation::nearest_neighbor< image2d<int> > nn(img);
debug::iota(img);
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Minor fix : Translation Rotation.
* mln/fun/x2x/translation.hh,
* mln/fun/x2x/rotation.hh: Fix wrong namespaces.
* sandbox/jardonnet/virtual/access.hh: Fix concept check.
mln/fun/x2x/rotation.hh | 2 +-
mln/fun/x2x/translation.hh | 6 ++----
sandbox/jardonnet/virtual/access.hh | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
Index: mln/fun/x2x/translation.hh
--- mln/fun/x2x/translation.hh (revision 2186)
+++ mln/fun/x2x/translation.hh (working copy)
@@ -53,10 +53,8 @@
*/
template <unsigned n, typename C>
struct translation
-
- : internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
- ,
- public Bijection_x2x< translation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
+ , public Bijection_x2x< translation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> > super_;
Index: mln/fun/x2x/rotation.hh
--- mln/fun/x2x/rotation.hh (revision 2186)
+++ mln/fun/x2x/rotation.hh (working copy)
@@ -53,7 +53,7 @@
*/
template <unsigned n, typename C>
struct rotation
- : internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
, public Bijection_x2x< rotation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> > super_;
Index: sandbox/jardonnet/virtual/access.hh
--- sandbox/jardonnet/virtual/access.hh (revision 2186)
+++ sandbox/jardonnet/virtual/access.hh (working copy)
@@ -112,7 +112,7 @@
access(const I& img, const mln_point(I)& p,
const T& trans, const F& interp)
{
- mlc_is(T, Bijection_x2x<T>)::check();
+ mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
mlc_is(F, Function_x2x<F>)::check();
return interp(img, (trans.inv())(p));
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: virtual transform, Add concept check.
* jardonnet/virtual/access.hh: Add concept check.
* jardonnet/virtual/access.cc: Update in consequence.
access.cc | 4 ++--
access.hh | 30 ++++++++++++++++++++++--------
2 files changed, 24 insertions(+), 10 deletions(-)
Index: jardonnet/virtual/access.hh
--- jardonnet/virtual/access.hh (revision 2185)
+++ jardonnet/virtual/access.hh (working copy)
@@ -3,7 +3,8 @@
# include <mln/core/image1d.hh>
# include <mln/core/image2d.hh>
-# include <mln/math/round.hh>
+# include <mln/metal/is.hh>
+# include <mln/core/concept/function.hh>
namespace mln
{
@@ -11,10 +12,13 @@
namespace interpolation
{
+ template < typename I >
struct nearest_neighbor
+ : public Function_x2x< nearest_neighbor<I> >
{
+ typedef mln_value(I) result;
- template <typename I, typename V>
+ template < typename V >
mln_value(I)
operator()(const I& img, const V& v) const
{
@@ -24,9 +28,13 @@
};
+ template < typename I >
struct linear
+ : public Function_x2x< linear<I> >
{
- template <typename I, typename C>
+ typedef mln_value(I) result;
+
+ template <typename C>
mln_value(I)
operator()(const I& img,
const algebra::vec<1,C>& v) const
@@ -43,7 +51,7 @@
return img(xa);
// p2
- double xb = mln_point(I)::coord(v[0] + 0.49999);
+ double xb = mln_point(I)::coord(v[0] + 1);
double yb = img(point1d(xb));
// Taylor-young
@@ -51,10 +59,13 @@
}
};
-
+ template < typename I >
struct bilinear
+ : public Function_x2x< bilinear<I> >
{
- template <typename I, typename V>
+ typedef mln_value(I) result;
+
+ template <typename V>
mln_value(I)
operator()(const I& img, const V& v) const
{
@@ -69,9 +80,9 @@
double y = v[1];
double x1 = mln_point(I)::coord(v[0]);
- double x2 = mln_point(I)::coord(v[0]+ 4.9999);
+ double x2 = mln_point(I)::coord(v[0]+ 1);
double y1 = mln_point(I)::coord(v[1]);
- double y2 = mln_point(I)::coord(v[1]+ 4.9999);
+ double y2 = mln_point(I)::coord(v[1]+ 1);
point2d q11 = point2d(x1, y1);
point2d q12 = point2d(x1, y2);
@@ -101,6 +112,9 @@
access(const I& img, const mln_point(I)& p,
const T& trans, const F& interp)
{
+ mlc_is(T, Bijection_x2x<T>)::check();
+ mlc_is(F, Function_x2x<F>)::check();
+
return interp(img, (trans.inv())(p));
}
Index: jardonnet/virtual/access.cc
--- jardonnet/virtual/access.cc (revision 2185)
+++ jardonnet/virtual/access.cc (working copy)
@@ -13,7 +13,7 @@
point2d p(5,5);
algebra::vec<2,float> v = make::vec(3,4);
fun::x2x::translation<2,float> t(v);
- interpolation::nearest_neighbor nn;
+ interpolation::nearest_neighbor< image2d<int> > nn;
debug::iota(img);
@@ -30,7 +30,7 @@
{
for (int j = 4; j < 54; j++)
std::cout <<
- access::access(img, point2d(i,j), t, nn);
+ mln::access::access(img, point2d(i,j), t, nn);
std::cout << std::endl;
}
}
1
0