* doc/examples-outputs.mk,
* doc/examples.mk,
* doc/outputs.mk: Regen.
* doc/examples.dox: Add link to new examples.
* doc/outputs/extended_image.txt,
* doc/outputs/transformed_image.txt,
* doc/examples/extended_image.cc,
* doc/examples/transformed_image.cc: New.
* doc/programs-examples.mk: Add new example programs.
* mln/core/image/dmorph/extended.hh,
* mln/core/image/dmorph/transformed_image.hh: Write documentation
and insert example code.
* mln/fun/p2p/fold.hh,
* mln/fun/p2p/mirror.hh,
* mln/fun/p2p/translation.hh: Make references to
transformed_image.
---
milena/ChangeLog | 26 ++++++++++
milena/doc/examples-outputs.mk | 36 ++++++++++++++
milena/doc/examples.dox | 5 ++
milena/doc/examples.mk | 2 +
milena/doc/examples/extended_image.cc | 51 ++++++++++++++++++++
milena/doc/examples/transformed_image.cc | 31 ++++++++++++
milena/doc/outputs.mk | 2 +
...-right-instantiation.txt => extended_image.txt} | 0
...ght-instantiation.txt => transformed_image.txt} | 0
milena/doc/programs-examples.mk | 7 ++-
milena/mln/core/image/dmorph/extended.hh | 41 ++++++++++++++--
milena/mln/core/image/dmorph/transformed_image.hh | 33 +++++++++++--
milena/mln/fun/p2p/fold.hh | 2 +-
milena/mln/fun/p2p/mirror.hh | 2 +-
milena/mln/fun/p2p/translation.hh | 8 +++-
15 files changed, 234 insertions(+), 12 deletions(-)
create mode 100644 milena/doc/examples/extended_image.cc
create mode 100644 milena/doc/examples/transformed_image.cc
copy milena/doc/outputs/{accu-right-instantiation.txt => extended_image.txt} (100%)
copy milena/doc/outputs/{accu-right-instantiation.txt => transformed_image.txt}
(100%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9cca6a5..90c97df 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,31 @@
2013-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Document extended and transformed_image morphers.
+
+ * doc/examples-outputs.mk,
+ * doc/examples.mk,
+ * doc/outputs.mk: Regen.
+
+ * doc/examples.dox: Add link to new examples.
+
+ * doc/outputs/extended_image.txt,
+ * doc/outputs/transformed_image.txt,
+ * doc/examples/extended_image.cc,
+ * doc/examples/transformed_image.cc: New.
+
+ * doc/programs-examples.mk: Add new example programs.
+
+ * mln/core/image/dmorph/extended.hh,
+ * mln/core/image/dmorph/transformed_image.hh: Write documentation
+ and insert example code.
+
+ * mln/fun/p2p/fold.hh,
+ * mln/fun/p2p/mirror.hh,
+ * mln/fun/p2p/translation.hh: Make references to
+ transformed_image.
+
+2013-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/core/site_set/box.hh: Add shrink() and to_smaller() members.
2013-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/doc/examples-outputs.mk b/milena/doc/examples-outputs.mk
index 51bba63..1136c55 100644
--- a/milena/doc/examples-outputs.mk
+++ b/milena/doc/examples-outputs.mk
@@ -127,6 +127,24 @@ $(srcdir)/outputs/extend.txt: $(srcdir)/examples/extend.stamp
fi
+$(srcdir)/examples/extended_image.stamp: examples/extended_image.cc
+ @rm -f $@.tmp
+ @touch $@.tmp
+ $(MAKE) $(AM_MAKEFLAGS) extended_image$(EXEEXT)
+ ./extended_image$(EXEEXT) >$(srcdir)/outputs/extended_image.txt.tmp
+ mv $(srcdir)/outputs/extended_image.txt.tmp $(srcdir)/outputs/extended_image.txt
+ @mv -f $@.tmp $@
+EXTRA_DIST += $(srcdir)/examples/extended_image.stamp
+MAINTAINERCLEANFILES += $(srcdir)/examples/extended_image.stamp
+
+$(srcdir)/outputs/extended_image.txt: $(srcdir)/examples/extended_image.stamp
+## Recover from the removal of $@
+ @if test -f $@; then :; else \
+ rm -f $<; \
+ $(MAKE) $(AM_MAKEFLAGS) $<; \
+ fi
+
+
$(srcdir)/examples/extension-ignore.stamp: examples/extension-ignore.cc
@rm -f $@.tmp
@touch $@.tmp
@@ -703,6 +721,24 @@ $(srcdir)/outputs/predicate-1.txt:
$(srcdir)/examples/predicate-1.stamp
fi
+$(srcdir)/examples/transformed_image.stamp: examples/transformed_image.cc
+ @rm -f $@.tmp
+ @touch $@.tmp
+ $(MAKE) $(AM_MAKEFLAGS) transformed_image$(EXEEXT)
+ ./transformed_image$(EXEEXT) >$(srcdir)/outputs/transformed_image.txt.tmp
+ mv $(srcdir)/outputs/transformed_image.txt.tmp $(srcdir)/outputs/transformed_image.txt
+ @mv -f $@.tmp $@
+EXTRA_DIST += $(srcdir)/examples/transformed_image.stamp
+MAINTAINERCLEANFILES += $(srcdir)/examples/transformed_image.stamp
+
+$(srcdir)/outputs/transformed_image.txt: $(srcdir)/examples/transformed_image.stamp
+## Recover from the removal of $@
+ @if test -f $@; then :; else \
+ rm -f $<; \
+ $(MAKE) $(AM_MAKEFLAGS) $<; \
+ fi
+
+
$(srcdir)/examples/tuto2_first_image.stamp: examples/tuto2_first_image.cc
@rm -f $@.tmp
@touch $@.tmp
diff --git a/milena/doc/examples.dox b/milena/doc/examples.dox
index ab18c38..1acb132 100644
--- a/milena/doc/examples.dox
+++ b/milena/doc/examples.dox
@@ -8,7 +8,12 @@
\li \link demos/inter_pixel/inter_pixel.cc Inter-pixel processings \endlink
+\section examplesmorpher Image Morphers
+\li \link doc/examples/transformed_image.cc Image domain translation. \endlink
+\li \link doc/examples/extended_image.cc Image domain extension/shrinking. \endlink
+
\section examplesgraph Graphs
\li \link demos/graph/region_adjacency_graph.cc Region Adjacency Graph \endlink
+
*/
diff --git a/milena/doc/examples.mk b/milena/doc/examples.mk
index c6542e4..12b9419 100644
--- a/milena/doc/examples.mk
+++ b/milena/doc/examples.mk
@@ -8,6 +8,7 @@ EXAMPLES = \
$(srcdir)/examples/dpoint-1.cc \
$(srcdir)/examples/estim-sites.cc \
$(srcdir)/examples/extend.cc \
+ $(srcdir)/examples/extended_image.cc \
$(srcdir)/examples/extension-ignore.cc \
$(srcdir)/examples/fill-call-1.cc \
$(srcdir)/examples/fill-imageif-cfun.cc \
@@ -40,6 +41,7 @@ EXAMPLES = \
$(srcdir)/examples/paste.cc \
$(srcdir)/examples/point-1.cc \
$(srcdir)/examples/predicate-1.cc \
+ $(srcdir)/examples/transformed_image.cc \
$(srcdir)/examples/trash/accu.cc \
$(srcdir)/examples/trash/box.cc \
$(srcdir)/examples/trash/cpp_issue.cc \
diff --git a/milena/doc/examples/extended_image.cc
b/milena/doc/examples/extended_image.cc
new file mode 100644
index 0000000..ed089f9
--- /dev/null
+++ b/milena/doc/examples/extended_image.cc
@@ -0,0 +1,51 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/dmorph/extended.hh>
+#include <mln/fun/p2p/translation.hh>
+
+int main()
+{
+ using namespace mln;
+
+//! [Input initialization]
+ /*
+ (-3,-3)--------.
+ | |
+ |(0,0)----. |
+ | | |---------> Effective domain
+ | .-----(3,3)
+ | |----> Image border (3 pixels, by default)
+ .----------(6,6)
+ */
+ typedef mln::image2d<bool> I;
+ I ima(4, 4);
+//! [Input initialization]
+
+//! [Shrink image domain]
+ mln::box2d b_shrink = ima.domain().to_smaller(1);
+ /*
+ (-3,-3)--------.
+ | |
+ |(1,1)----. |
+ | | |---------> Effective domain
+ | .-----(2,2)
+ | |----> Image border (4 pixels)
+ .----------(6,6)
+ */
+ mln::extended<I> ima_shrink = mln::extended_to(ima, b_shrink);
+//! [Shrink image domain]
+
+//! [Extend image domain]
+ mln::box2d b_extend = ima.domain().to_larger(1);
+ /*
+ (-3,-3)--------.
+ | |
+ (-1,-1)---. |
+ | | |---------> Effective domain
+ | .-----(4,4)
+ | |----> Image border (2 pixels)
+ .----------(6,6)
+ */
+ mln::extended<I> ima_extend = mln::extended_to(ima, b_extend);
+//! [Extend image domain]
+
+}
diff --git a/milena/doc/examples/transformed_image.cc
b/milena/doc/examples/transformed_image.cc
new file mode 100644
index 0000000..f4302d3
--- /dev/null
+++ b/milena/doc/examples/transformed_image.cc
@@ -0,0 +1,31 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/dmorph/transformed_image.hh>
+#include <mln/fun/p2p/translation.hh>
+
+int main()
+{
+ using namespace mln;
+
+//! [Translate image domain]
+ /*
+ (0,0)----.
+ | |
+ .-----(2,2)
+ */
+ typedef mln::image2d<bool> I;
+ I ima(3, 3);
+
+ // Translation delta-point of row+2 and col-1.
+ mln::dpoint2d translate_dp(+2, -1);
+ typedef mln::fun::p2p::translation_t<point2d> F;
+ F translate_fun(translate_dp);
+
+ /*
+ (2,-1)---.
+ | |
+ .-----(4,1)
+ */
+ mln::transformed_image<I,F>
+ ext_ima = mln::transform_domain(ima, translate_fun);
+//! [Translate image domain]
+}
diff --git a/milena/doc/outputs.mk b/milena/doc/outputs.mk
index 383f95a..40fa6c3 100644
--- a/milena/doc/outputs.mk
+++ b/milena/doc/outputs.mk
@@ -8,6 +8,7 @@ OUTPUTS = \
$(srcdir)/outputs/dpoint-1.txt \
$(srcdir)/outputs/estim-sites.txt \
$(srcdir)/outputs/extend.txt \
+ $(srcdir)/outputs/extended_image.txt \
$(srcdir)/outputs/extension-ignore.txt \
$(srcdir)/outputs/fill-call-1.txt \
$(srcdir)/outputs/fill-imageif-cfun.txt \
@@ -40,6 +41,7 @@ OUTPUTS = \
$(srcdir)/outputs/paste.txt \
$(srcdir)/outputs/point-1.txt \
$(srcdir)/outputs/predicate-1.txt \
+ $(srcdir)/outputs/transformed_image.txt \
$(srcdir)/outputs/tuto2_first_image.txt \
$(srcdir)/outputs/tuto3_colorize.txt \
$(srcdir)/outputs/tuto3_first_routine.txt \
diff --git a/milena/doc/outputs/accu-right-instantiation.txt
b/milena/doc/outputs/extended_image.txt
similarity index 100%
copy from milena/doc/outputs/accu-right-instantiation.txt
copy to milena/doc/outputs/extended_image.txt
diff --git a/milena/doc/outputs/accu-right-instantiation.txt
b/milena/doc/outputs/transformed_image.txt
similarity index 100%
copy from milena/doc/outputs/accu-right-instantiation.txt
copy to milena/doc/outputs/transformed_image.txt
diff --git a/milena/doc/programs-examples.mk b/milena/doc/programs-examples.mk
index 6a81b02..42610c4 100644
--- a/milena/doc/programs-examples.mk
+++ b/milena/doc/programs-examples.mk
@@ -1,6 +1,7 @@
## Program as examples, generating images & outputs. -*- Makefile-Automake -*-
-## Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
+## Copyright (C) 2010, 2013 EPITA Research and Development Laboratory
+## (LRDE).
##
## This file is part of Olena.
##
@@ -32,6 +33,7 @@ PROGRAMS_examples = \
dpoint-1 \
estim-sites \
extend \
+ extended_image \
extension-ignore \
fill \
fill-call-1 \
@@ -64,6 +66,7 @@ PROGRAMS_examples = \
paste-call-1 \
point-1 \
predicate-1 \
+ transformed_image \
win-create-1 \
win-create-2
@@ -96,6 +99,7 @@ domain_display_SOURCES = examples/domain-display.cc
dpoint_1_SOURCES = examples/dpoint-1.cc
estim_sites_SOURCES = examples/estim-sites.cc
extend_SOURCES = examples/extend.cc
+extended_image_SOURCES = examples/extended_image.cc
extension_ignore_SOURCES = examples/extension-ignore.cc
fill_SOURCES = examples/fill.cc
fill_call_1_SOURCES = examples/fill-call-1.cc
@@ -128,6 +132,7 @@ paste_SOURCES = examples/paste.cc
paste_call_1_SOURCES = examples/paste-call-1.cc
point_1_SOURCES = examples/point-1.cc
predicate_1_SOURCES = examples/predicate-1.cc
+transformed_image_SOURCES = examples/transformed_image.cc
win_create_1_SOURCES = examples/win-create-1.cc
win_create_2_SOURCES = examples/win-create-2.cc
diff --git a/milena/mln/core/image/dmorph/extended.hh
b/milena/mln/core/image/dmorph/extended.hh
index 0864b10..00d7823 100644
--- a/milena/mln/core/image/dmorph/extended.hh
+++ b/milena/mln/core/image/dmorph/extended.hh
@@ -86,11 +86,28 @@ namespace mln
} // end of namespace mln::trait
+ /*! \brief An image of which domain is extended/shrunk.
- /// Makes an image become restricted by a point set.
- ///
- /// \ingroup modimagedomainmorpher
- //
+ This morpher can be used to alter the current domain of an image
+ by extending or shrinking the existing domain.
+
+ \warning Altering the domain may require that values are available
+ for every sites. While extending outside the original domain, this
+ routine relies on the image border. Therefore, be sure it is large
+ enough to handle the new domain.
+
+ Input used in the following example:
+ \snippet extended_image.cc Input initialization
+
+ Example on how to extend the domain:
+ \snippet extended_image.cc Extend image domain
+
+ Example on how to shrink the domain:
+ \snippet extended_image.cc Extend image domain
+
+ \sa extended_to mln::extend mln::extension_ima mln::extension_fun mln::extension_val
+ \ingroup modimagedomainmorpher
+ */
template <typename I>
struct extended : public internal::image_domain_morpher< I,
box<mln_site(I)>,
@@ -126,10 +143,26 @@ namespace mln
/// \endcond
+ /*!
+ \brief Creates an extended image.
+
+ This routine is provided for convenience and can be considered as
+ a "factory" of mln::extended image.
+
+ \relates mln::extended
+ */
template <typename I, typename B>
extended<const I>
extended_to(const Image<I>& ima, const Box<B>& b);
+ /*!
+ \brief Creates an extended image.
+
+ This routine is provided for convenience and can be considered as
+ a "factory" of mln::extended images.
+
+ \relates mln::extended
+ */
template <typename I, typename B>
extended<I>
extended_to(Image<I>& ima, const Box<B>& b);
diff --git a/milena/mln/core/image/dmorph/transformed_image.hh
b/milena/mln/core/image/dmorph/transformed_image.hh
index d2bee12..95ec6bc 100644
--- a/milena/mln/core/image/dmorph/transformed_image.hh
+++ b/milena/mln/core/image/dmorph/transformed_image.hh
@@ -89,11 +89,20 @@ namespace mln
} // end of namespace mln::trait
+ /*! \brief An image of which domain is transformed by a function.
- /// Image having its domain restricted by a site set.
- ///
- /// \ingroup modimagedomainmorpher
- //
+ This morpher can be used to modify the image domain through a
+ function.
+
+ This morpher expects the actual transformation for construction
+ but uses internally the inverted transformation.
+
+ Example (\link transformed_image.cc \endlink):
+ \snippet transformed_image.cc Translate image domain
+
+ \sa mln::transform_domain fun::p2p::translation_t fun::p2p::mirror fun::p2p::fold
+ \ingroup modimagedomainmorpher
+ */
template <typename I, typename F>
struct transformed_image : public internal::image_domain_morpher< I,
p_transformed< mln_domain(I), F>,
@@ -134,10 +143,26 @@ namespace mln
// Morpher creation.
+ /*!
+ \brief Creates a transformed image.
+
+ This routine is provided for convenience and can be considered as
+ a "factory" of mln::transformed_image images.
+
+ \relates transformed_image
+ */
template <typename I, typename F>
transformed_image<const I, F>
transform_domain(const Image<I>& ima, const Function_v2v<F>& f);
+ /*!
+ \brief Creates a transformed image.
+
+ This routine is provided for convenience and can be considered as
+ a "factory" of mln::transformed_image images.
+
+ \relates transformed_image
+ */
template <typename I, typename F>
transformed_image<I, F>
transform_domain(Image<I>& ima, const Function_v2v<F>& f);
diff --git a/milena/mln/fun/p2p/fold.hh b/milena/mln/fun/p2p/fold.hh
index 5f0e4f4..814c4d2 100644
--- a/milena/mln/fun/p2p/fold.hh
+++ b/milena/mln/fun/p2p/fold.hh
@@ -47,7 +47,7 @@ namespace mln
/*!
\brief Fold a domain into one direction.
- \sa data::transform
+ \sa data::transform mln::transformed_image
\ingroup funv2v
*/
template < typename P,
diff --git a/milena/mln/fun/p2p/mirror.hh b/milena/mln/fun/p2p/mirror.hh
index 7f307dc..2c6bfe9 100644
--- a/milena/mln/fun/p2p/mirror.hh
+++ b/milena/mln/fun/p2p/mirror.hh
@@ -63,7 +63,7 @@ namespace mln
// p == (0, 1);
\endcode
- \sa data::transform
+ \sa data::transform mln::transformed_image
\ingroup funv2v
*/
template <typename B>
diff --git a/milena/mln/fun/p2p/translation.hh b/milena/mln/fun/p2p/translation.hh
index c122cfd..69ef48b 100644
--- a/milena/mln/fun/p2p/translation.hh
+++ b/milena/mln/fun/p2p/translation.hh
@@ -49,7 +49,7 @@ namespace mln
\brief Computes the translation of a given point w.r.t a
translation vector.
- \sa data::transform
+ \sa data::transform mln::transformed_image
\ingroup funv2v
*/
template <typename P>
@@ -68,6 +68,12 @@ namespace mln
};
+ /*!
+ \brief Creates a translation function.
+
+ \relates mln::fun::p2p::translation_t
+ \ingroup funv2v
+ */
template <typename D>
translation_t<mln_site(D)>
translation(const Gdpoint<D>& dp);
--
1.7.2.5