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
---
milena/ChangeLog | 8 ++++++++
milena/mln/geom/max_col.hh | 3 ++-
milena/mln/geom/max_row.hh | 3 ++-
milena/mln/geom/min_col.hh | 3 ++-
milena/mln/geom/min_row.hh | 3 ++-
5 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e1d1927..734d001 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Use geom::bbox instead of bbox().
+ * milena/mln/geom/max_col.hh,
+ * milena/mln/geom/max_row.hh,
+ * milena/mln/geom/min_col.hh,
+ * milena/mln/geom/min_col.hh: Use geom::bbox().
+
2008-10-14 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some fixes on level update and compute.
diff --git a/milena/mln/geom/max_col.hh b/milena/mln/geom/max_col.hh
index fa1b644..31cbb9a 100644
--- a/milena/mln/geom/max_col.hh
+++ b/milena/mln/geom/max_col.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
namespace mln
@@ -57,7 +58,7 @@ namespace mln
mln_deduce(I, site, coord) max_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmax().col();
+ return geom::bbox(ima).pmax().col();
}
diff --git a/milena/mln/geom/max_row.hh b/milena/mln/geom/max_row.hh
index 1b51db5..5697a4a 100644
--- a/milena/mln/geom/max_row.hh
+++ b/milena/mln/geom/max_row.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
namespace mln
@@ -58,7 +59,7 @@ namespace mln
mln_coord(I) max_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmax().row();
+ return geom::bbox(ima).pmax().row();
}
diff --git a/milena/mln/geom/min_col.hh b/milena/mln/geom/min_col.hh
index 90fdc4b..6993d6f 100644
--- a/milena/mln/geom/min_col.hh
+++ b/milena/mln/geom/min_col.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
namespace mln
@@ -58,7 +59,7 @@ namespace mln
mln_coord(I) min_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmin().col();
+ return geom::bbox(ima).pmin().col();
}
diff --git a/milena/mln/geom/min_row.hh b/milena/mln/geom/min_row.hh
index 73089cd..5f2c191 100644
--- a/milena/mln/geom/min_row.hh
+++ b/milena/mln/geom/min_row.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
# include <mln/metal/bexpr.hh>
# include <mln/metal/int.hh>
@@ -61,7 +62,7 @@ namespace mln
mln_deduce(I, site, coord) min_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmin().row();
+ return geom::bbox(ima).pmin().row();
}
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM Bootstrap Classification.
Bootstrap classification:
* classif/Makefile: New.
* classif/iccvg04.cc: New.
Add test image:
* classif/chiche.pgm: New.
* classif/images/caf_0009.jpg: New.
* classif/images/caf_0028.jpg: New.
* classif/images/edfverso06.JPG: New.
* classif/images/capture.png: New.
* classif/images/vpc_0001.jpg: New.
* classif/images/caf_0010.jpg: New.
* classif/images/caf_0013.jpg: New.
* classif/images/caf_0005.jpg: New.
* classif/images/caf_0034.jpg: New.
* classif/lena.ppm: New.
* classif/scoolNBR.ppm: New.
classif/Makefile | 2
classif/iccvg04.cc | 50
classif/lena.ppm | 541
classif/scoolNBR.ppm |960004
++++++++++++++++++++++++++++++++++++++
jardonnet/registration/center.hh | 7
jardonnet/registration/exp_val.hh | 6
6 files changed, 960601 insertions(+), 9 deletions(-)
Index: jardonnet/registration/exp_val.hh
--- jardonnet/registration/exp_val.hh (revision 2549)
+++ jardonnet/registration/exp_val.hh (working copy)
@@ -58,11 +58,7 @@
algebra::vec<P::dim,float> c(literal::zero);
for (unsigned i = 0; i < a.nsites(); ++i)
- {
- // FIXME : Ugly.
- algebra::vec<P::dim,float> ai = a[i];
- c += ai;
- }
+ c += convert::to< algebra::vec<P::dim,float> > (a[i]);
return c / a.nsites();
}
Index: jardonnet/registration/cross_cov.hh
Index: jardonnet/registration/center.hh
--- jardonnet/registration/center.hh (revision 2549)
+++ jardonnet/registration/center.hh (working copy)
@@ -55,9 +55,8 @@
algebra::vec<P::dim,float> c(literal::zero);
for (unsigned i = 0; i < a.nsites(); ++i)
{
- // FIXME : Ugly.
- algebra::vec<P::dim,float> ai = a[i];
- c += ai;
+ //algebra::vec<P::dim,float> ai = a[i];
+ c += convert::to< algebra::vec<P::dim,float> > (ai);
}
return algebra::to_point<P>(c / a.nsites());
@@ -70,4 +69,4 @@
} // end of namespace mln
-#endif // ! MLN_MATH_ABS_HH
+#endif // ! MLN_GEOM_CENTER_HH
Index: classif/iccvg04.cc
--- classif/iccvg04.cc (revision 0)
+++ classif/iccvg04.cc (revision 0)
@@ -0,0 +1,50 @@
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/histo/data.hh>
+#include <mln/value/all.hh>
+
+#include <mln/level/fill.hh>
+
+#include <mln/io/ppm/load.hh>
+
+#include <mln/io/pgm/save.hh>
+
+using namespace mln;
+
+template <typename I>
+mln::image3d<unsigned>
+fill_histo(const I& ima)
+{
+ image3d<unsigned> histo(256,256,256);
+ level::fill(histo, 0);
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ point3d p3(ima(p).red(),ima(p).green(), ima(p).blue());
+ histo(p3)++;
+ }
+ return histo;
+}
+
+int main(int argc, char **argv)
+{
+ image2d<value::rgb8> ima;
+ ima = io::ppm::load<value::rgb8>(argv[1]);
+
+ image3d<unsigned> histo = fill_histo(ima);
+
+ image2d< value::int_u16 > out(256,256);
+ level::fill(out, 0);
+ mln_piter_(image2d< value::int_u16 >) p(out.domain());
+ for_all(p)
+ {
+ for (unsigned i = 0; i < 256; i++)
+ if ((out(p) + histo(point3d(p[0],p[1],i))) < 65536)
+ out(p) += histo(point3d(p[0],p[1],i));
+ }
+ io::pgm::save(out,"./chiche.pgm");
+}
Index: classif/chiche.pgm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/chiche.pgm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0009.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0009.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0028.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0028.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/edfverso06.JPG
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/edfverso06.JPG
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/capture.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/capture.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/vpc_0001.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/vpc_0001.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0010.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0010.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0013.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0013.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0005.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0005.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0034.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0034.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/lena.ppm
--- classif/lena.ppm (revision 0)
+++ classif/lena.ppm (revision 0)
Cannot display
Index: classif/Makefile
--- classif/Makefile (revision 0)
+++ classif/Makefile (revision 0)
@@ -0,0 +1,2 @@
+all:
+ g++ *.cc -I../../ -O3
\ 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>
Some fixes on level update and compute.
* mln/level/update.hh: Fix missing 'inline'.
Remove useless include.
* mln/level/compute.hh: Rely on level::update.
Remove redundant code.
compute.hh | 125 ++++---------------------------------------------------------
update.hh | 6 ++
2 files changed, 15 insertions(+), 116 deletions(-)
Index: mln/level/update.hh
--- mln/level/update.hh (revision 2548)
+++ mln/level/update.hh (working copy)
@@ -35,7 +35,6 @@
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/meta_accumulator.hh>
@@ -92,6 +91,7 @@
{
template <typename A, typename I>
+ inline
mln_result(A)
update(Accumulator<A>& a_, const Image<I>& input_)
{
@@ -113,6 +113,7 @@
template <typename A, typename I>
+ inline
mln_result(A)
update_fastest(Accumulator<A>& a_, const Image<I>& input_)
{
@@ -141,6 +142,7 @@
{
template <typename A, typename I>
+ inline
mln_result(A)
update_dispatch(trait::image::speed::any,
Accumulator<A>& a, const Image<I>& input)
@@ -149,6 +151,7 @@
}
template <typename A, typename I>
+ inline
mln_result(A)
update_dispatch(trait::image::speed::fastest,
Accumulator<A>& a, const Image<I>& input)
@@ -157,6 +160,7 @@
}
template <typename A, typename I>
+ inline
mln_result(A)
update_dispatch(Accumulator<A>& a, const Image<I>& input)
{
Index: mln/level/compute.hh
--- mln/level/compute.hh (revision 2548)
+++ mln/level/compute.hh (working copy)
@@ -33,8 +33,7 @@
* \brief Compute an accumulator onto image pixel values.
*/
-# include <mln/core/concept/accumulator.hh>
-# include <mln/core/concept/image.hh>
+# include <mln/level/update.hh>
# include <mln/core/concept/meta_accumulator.hh>
@@ -50,6 +49,8 @@
* \param[in] a An accumulator.
* \param[in] input The input image.
* \return The accumulator result.
+ *
+ * It fully relies on level::update.
*/
template <typename A, typename I>
mln_result(A)
@@ -71,133 +72,27 @@
# ifndef MLN_INCLUDE_ONLY
- // Tests.
-
- namespace internal
- {
+ // Facades.
template <typename A, typename I>
inline
- void
- compute_tests(const Accumulator<A>& a_, const Image<I>& input_)
- {
- const A& a = exact(a_);
- const I& input = exact(input_);
- mln_precondition(input.has_data());
- // sizeof(a.take(mln_value(I)()));
-
- (void) a;
- (void) input;
- }
-
- } // end of namespace internal
-
-
-
- // Implementations.
-
- namespace impl
- {
-
- namespace generic
- {
-
- template <typename A, typename I>
mln_result(A)
- compute(const Accumulator<A>& a_, const Image<I>& input_)
+ compute(const Accumulator<A>& a_, const Image<I>& input)
{
- trace::entering("level::impl::generic::compute");
-
- A a = exact(a_);
- const I& input = exact(input_);
- internal::compute_tests(a, input);
-
- a.init();
- mln_piter(I) p(input.domain());
- for_all(p)
- a.take(input(p));
-
- trace::exiting("level::impl::generic::compute");
- return a.to_result();
- }
-
- } // end of namespace mln::level::impl::generic
-
-
- template <typename A, typename I>
- mln_result(A)
- compute_fastest(const Accumulator<A>& a_, const Image<I>& input_)
- {
- trace::entering("level::impl::compute_fastest");
+ trace::entering("level::compute");
A a = exact(a_);
- const I& input = exact(input_);
- internal::compute_tests(a, input);
+ level::internal::update_tests(a, input);
a.init();
- mln_pixter(const I) pxl(input);
- for_all(pxl)
- a.take(pxl.val());
-
- trace::exiting("level::impl::compute_fastest");
- return a.to_result();
- }
-
-
- } // end of namespace mln::level::impl
-
-
-
- // Dispatch.
-
- namespace internal
- {
-
- template <typename A, typename I>
- mln_result(A)
- compute_dispatch(trait::image::speed::any,
- const Accumulator<A>& a, const Image<I>& input)
- {
- return impl::generic::compute(a, input);
- }
-
- template <typename A, typename I>
- mln_result(A)
- compute_dispatch(trait::image::speed::fastest,
- const Accumulator<A>& a, const Image<I>& input)
- {
- return impl::compute_fastest(a, input);
- }
-
- template <typename A, typename I>
- mln_result(A)
- compute_dispatch(const Accumulator<A>& a, const Image<I>& input)
- {
- return compute_dispatch(mln_trait_image_speed(I)(),
- a, input);
- }
-
- } // end of namespace internal
-
-
-
- // Facades.
-
- template <typename A, typename I>
- inline
- mln_result(A)
- compute(const Accumulator<A>& a, const Image<I>& input)
- {
- trace::entering("level::compute");
-
- internal::compute_tests(a, input);
- mln_result(A) r = internal::compute_dispatch(a, input);
+ level::internal::update_dispatch(a, input);
trace::exiting("level::compute");
- return r;
+ return a;
}
template <typename A, typename I>
+ inline
mln_accu_with(A, mln_value(I))::result
compute(const Meta_Accumulator<A>&, const Image<I>& input)
{
1
0
cleanup-2008 2547: Reactivate dispatch in the fill_with_value algorithm.
by Nicolas Ballas 14 Oct '08
by Nicolas Ballas 14 Oct '08
14 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Reactivate dispatch in the fill_with_value algorithm.
* tests/level/fill_with_value.cc: Update.
* mln/trait/images.hh,
* mln/core/image/flat_image.hh,
* mln/core/image/image1d.hh,
* mln/core/image/image3d.hh: Update properties.
* mln/level/fill_with_value.spe.hh: Add dispatch.
* mln/level/fill_with_value.hh: Comment irrelevant tests.
mln/core/image/flat_image.hh | 28 ++++++++++
mln/core/image/image1d.hh | 4 +
mln/core/image/image3d.hh | 4 +
mln/level/fill_with_value.hh | 6 +-
mln/level/fill_with_value.spe.hh | 100 +++++++++++++++++++++++++++++++++++----
mln/trait/images.hh | 8 +++
tests/level/fill_with_value.cc | 34 ++++++++++++-
7 files changed, 171 insertions(+), 13 deletions(-)
Index: tests/level/fill_with_value.cc
--- tests/level/fill_with_value.cc (revision 2547)
+++ tests/level/fill_with_value.cc (working copy)
@@ -30,19 +30,49 @@
* \brief Tests on mln::level::fill_with_value
*/
-#include <mln/core/image/image2d.hh>
#include <mln/level/fill_with_value.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/image_if.hh>
+
+#include <mln/fun/p2b/chess.hh>
int main()
{
using namespace mln;
-
const unsigned size = 100;
+ {
image2d<unsigned char> ima(size, size);
level::fill_with_value(ima, 51);
box2d::piter p(ima.domain());
for_all(p)
mln_assertion(ima(p) == 51);
}
+
+
+ {
+ flat_image<short, box2d> ima(5, make::box2d(2, 3));
+ level::fill_with_value(ima, 51);
+ box2d::piter p(ima.domain());
+ for_all(p)
+ mln_assertion(ima(p) == 51);
+ }
+
+
+ {
+ typedef image2d<unsigned char> I;
+ typedef image_if<I, fun::p2b::chess_t> II;
+
+ I ima(size, size);
+ level::fill_with_value(ima, 51);
+
+ II ima_if = ima | fun::p2b::chess;
+ level::fill_with_value(ima_if, 42);
+
+ II::piter p(ima_if.domain());
+ for_all(p)
+ mln_assertion(ima_if(p) == 42);
+ }
+}
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 2547)
+++ mln/trait/images.hh (working copy)
@@ -59,6 +59,10 @@
# define mln_trait_image_value_storage(I) typename mln::trait::image_< I >::value_storage
# define mln_trait_image_value_browsing(I) typename mln::trait::image_< I >::value_browsing
# define mln_trait_image_value_io(I) typename mln::trait::image_< I >::value_io
+# define mln_trait_image_pw_io(I) typename mln::trait::image_< I >::pw_io
+# define mln_trait_image_vw_io(I) typename mln::trait::image_< I >::vw_io
+# define mln_trait_image_vw_set(I) typename mln::trait::image_< I >::vw_set
+# define mln_trait_image_value_alignement(I) typename mln::trait::image_< I>::value_alignement
# define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization
# define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension
@@ -122,12 +126,16 @@
typedef undef size;
// value
+ typedef undef vw_io;
+ typedef undef vw_set;
+ typedef undef value_alignement;
typedef undef value_access;
typedef undef value_storage;
typedef undef value_browsing;
typedef undef value_io;
// site
+ typedef undef pw_io;
typedef undef localization;
typedef undef dimension;
Index: mln/core/image/flat_image.hh
--- mln/core/image/flat_image.hh (revision 2547)
+++ mln/core/image/flat_image.hh (working copy)
@@ -77,12 +77,16 @@
typedef trait::image::size::regular size;
// value
+ typedef trait::image::vw_io::read_write vw_io;
+ typedef trait::image::vw_set::none vw_set;
typedef trait::image::value_access::direct value_access;
- typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_storage::singleton value_storage;
typedef mln::trait::image::value_browsing::value_wise value_browsing;
+ typedef trait::image::value_alignement::with_grid value_alignement;
typedef trait::image::value_io::read_only value_io;
// site / domain
+ typedef trait::image::pw_io::read pw_io;
typedef trait::image::localization::basic_grid localization; // FIXME
typedef trait::image::dimension::two_d dimension; // FIXME
@@ -140,6 +144,8 @@
/// Change the image value.
void change_value(const T& old_val, const T& new_val);
+ const T& val() const;
+ T& val();
};
@@ -248,6 +254,26 @@
this->data_->val_ = new_val;
}
+ template <typename T, typename S>
+ inline
+ const T&
+ flat_image<T,S>::val() const
+ {
+ mln_precondition(this->has_data());
+ return this->data_->val_;
+ }
+
+ template <typename T, typename S>
+ inline
+ T&
+ flat_image<T,S>::val()
+ {
+ mln_precondition(this->has_data());
+ return this->data_->val_;
+ }
+
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2547)
+++ mln/core/image/image1d.hh (working copy)
@@ -93,12 +93,16 @@
typedef trait::image::size::regular size;
// value
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_alignement::with_grid value_alignement;
typedef trait::image::value_io::read_write value_io;
// site / domain
+ typedef trait::image::pw_io::read_write pw_io;
typedef trait::image::localization::basic_grid localization;
typedef trait::image::dimension::one_d dimension;
Index: mln/core/image/image3d.hh
--- mln/core/image/image3d.hh (revision 2547)
+++ mln/core/image/image3d.hh (working copy)
@@ -96,12 +96,16 @@
typedef trait::image::size::regular size;
// value
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_alignement::with_grid value_alignement;
typedef trait::image::value_io::read_write value_io;
// site / domain
+ typedef trait::image::pw_io::read_write pw_io;
typedef trait::image::localization::basic_grid localization;
typedef trait::image::dimension::three_d dimension;
Index: mln/level/fill_with_value.spe.hh
--- mln/level/fill_with_value.spe.hh (revision 2547)
+++ mln/level/fill_with_value.spe.hh (working copy)
@@ -37,6 +37,7 @@
# error "Forbidden inclusion of *.spe.hh"
# endif // ! MLN_LEVEL_FILL_WITH_VALUE_HH
+# include <mln/level/memset_.hh>
# ifndef MLN_INCLUDE_ONLY
@@ -80,11 +81,7 @@
I& ima = exact(ima_);
internal::fill_with_value_tests(ima, val);
- // level::memset_(ima, ima.point_at_index(0), v, ima.nelements());
- const unsigned n = ima.nelements();
- mln_value(I)* ptr = ima.buffer();
- for (unsigned i = 0; i < n; ++i)
- *ptr++ = val;
+ level::memset_(ima, ima.point_at_index(0), val, ima.nelements());
trace::exiting("level::impl::fill_with_value_one_block");
}
@@ -98,16 +95,31 @@
I& ima = exact(ima_);
internal::fill_with_value_tests(ima, val);
- mln_viter(I) v(ima.values());
+ mln_viter(I) v(ima.cells());
for_all(v)
v.change_to(val);
trace::exiting("level::impl::fill_with_value_cell_wise");
}
+ template <typename I, typename V>
+ inline
+ void fill_with_value_singleton(Image<I>& ima_, const V& val)
+ {
+ trace::entering("level::impl::fill_with_value_singleton");
+
+ I& ima = exact(ima_);
+ internal::fill_with_value_tests(ima, val);
+
+ ima.val() = val;
+
+ trace::exiting("level::impl::fill_with_value_singleton");
+ }
+
} // end of namespace mln::level::impl
+
// Dispatch.
// ---------
@@ -115,12 +127,84 @@
{
template <typename I, typename V>
- inline
- void fill_with_value_dispatch(Image<I>& ima, const V& val)
+ void fill_with_value_dispatch(trait::image::value_storage::one_block,
+ trait::image::vw_io::any,
+ Image<I>& ima, const V& val)
+ {
+ if ((mlc_is(mln_trait_image_pw_io(I),
+ trait::image::pw_io::read_write)::value ||
+ mlc_is(mln_trait_image_vw_io(I),
+ trait::image::vw_io::read_write)::value) &&
+ mlc_is(mln_trait_image_value_access(I),
+ trait::image::value_access::direct)::value)
+ impl::fill_with_value_one_block(ima, val);
+ else
+ impl::generic::fill_with_value(ima, val);
+ }
+
+ template <typename I, typename V>
+ void fill_with_value_dispatch(trait::image::value_storage::singleton,
+ trait::image::vw_io::any,
+ Image<I>& ima, const V& val)
+ {
+ if ((mlc_is(mln_trait_image_pw_io(I),
+ trait::image::pw_io::read_write)::value ||
+ mlc_is(mln_trait_image_vw_io(I),
+ trait::image::vw_io::read_write)::value) &&
+ mlc_is(mln_trait_image_value_access(I),
+ trait::image::value_access::direct)::value)
+ impl::fill_with_value_singleton(ima, val);
+ }
+
+ template <typename I, typename V>
+ void fill_with_value_dispatch(trait::image::value_storage::piecewise,
+ trait::image::vw_io::any,
+ Image<I>& ima, const V& val)
+ {
+ /// FIXME
+ }
+
+
+ template <typename I, typename V>
+ void fill_with_value_dispatch(trait::image::value_storage::disrupted,
+ trait::image::vw_io::read_write,
+ Image<I>& ima, const V& val)
+ {
+ impl::fill_with_value_cell_wise(ima, val);
+ }
+
+
+
+ template <typename I, typename V>
+ void fill_with_value_dispatch(trait::image::value_storage::disrupted,
+ trait::image::vw_io::read,
+ Image<I>& ima, const V& val)
+ {
+ impl::generic::fill_with_value(ima, val);
+ }
+
+
+ /// FIXME:
+ // This specialization is only here to deal with image which have
+ // non-updated properties (vw_io).
+ template <typename I, typename V>
+ void fill_with_value_dispatch(trait::image::value_storage::any,
+ trait::undef,
+ Image<I>& ima, const V& val)
{
impl::generic::fill_with_value(ima, val);
}
+
+
+ template <typename I, typename V>
+ void fill_with_value_dispatch(Image<I>& ima, const V& val)
+ {
+ fill_with_value_dispatch(mln_trait_image_value_storage(I)(),
+ mln_trait_image_vw_io(I)(),
+ ima, val);
+ }
+
} // end of namespace mln::level::internal
Index: mln/level/fill_with_value.hh
--- mln/level/fill_with_value.hh (revision 2547)
+++ mln/level/fill_with_value.hh (working copy)
@@ -84,8 +84,10 @@
// is not defined.
(void) ima;
- mlc_is(mln_trait_image_value_io(I),
- mln::trait::image::value_io::read_write)::check();
+ // FIXME
+ //mlc_is(mln_trait_image_value_io(I),
+ //mln::trait::image::value_io::read_write)::check();
+
mlc_converts_to(mln_exact(V), mln_value(I))::check();
mln_precondition(exact(ima).has_data());
}
1
0
cleanup-2008 2547: Move some meta-acc into meta:: and revamp level take'n compute.
by Thierry Geraud 14 Oct '08
by Thierry Geraud 14 Oct '08
14 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move some meta-acc into meta:: and revamp level take'n compute.
* mln/level/take.spe.hh,
* mln/level/take.hh: Merge both files into as...
* mln/level/update.hh: ...this single new one.
Update.
* tests/level/take.cc: Rename as...
* tests/level/update.cc: ...this.
* tests/level/Makefile.am: Update.
* mln/level/compute.hh: Change sig.
* mln/accu/min.hh,
* mln/accu/max.hh,
* mln/accu/min_max.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/mean.hh: Move meta-accumulator into the meta::
namespace.
* mln/estim/sum.hh,
* mln/estim/min_max.hh,
* mln/estim/mean.hh,
* tests/level/compute_full.cc,
* tests/level/compute.cc: Update.
* tests/estim/min_max.cc: New.
* tests/estim/Makefile.am: Update.
mln/accu/max.hh | 11 +--
mln/accu/mean.hh | 11 +--
mln/accu/min.hh | 14 ++-
mln/accu/min_max.hh | 5 +
mln/accu/pair.hh | 10 +-
mln/accu/sum.hh | 9 +-
mln/estim/mean.hh | 8 +-
mln/estim/min_max.hh | 8 +-
mln/estim/sum.hh | 6 -
mln/level/compute.hh | 158 ++++++++++++++++++++++++++++++++++++--------
mln/level/update.hh | 141 +++++++++++++++++++++++++++++++--------
tests/estim/Makefile.am | 4 -
tests/estim/min_max.cc | 52 ++++++++++++++
tests/level/Makefile.am | 6 -
tests/level/compute.cc | 12 +--
tests/level/compute_full.cc | 22 +++---
tests/level/update.cc | 21 ++---
17 files changed, 379 insertions(+), 119 deletions(-)
Index: tests/level/compute_full.cc
--- tests/level/compute_full.cc (revision 2546)
+++ tests/level/compute_full.cc (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
@@ -116,8 +116,8 @@
accu::min_<I> acu_min;
accu::max_<I> acu_max;
- I min = level::compute(ima, acu_min);
- I max = level::compute(ima, acu_max);
+ I min = level::compute(acu_min, ima);
+ I max = level::compute(acu_max, ima);
mln_assertion(min == real_min);
mln_assertion(max == real_max);
}
@@ -128,8 +128,8 @@
accu::min_<I> acu_min;
accu::max_<I> acu_max;
- I min = level::compute(sub_ima, acu_min);
- I max = level::compute(sub_ima, acu_max);
+ I min = level::compute(acu_min, sub_ima);
+ I max = level::compute(acu_max, sub_ima);
mln_assertion(min == real_min2);
mln_assertion(max == real_max2);
}
@@ -141,8 +141,8 @@
accu::min_<I> acu_min;
accu::max_<I> acu_max;
- I min = level::compute(if_ima, acu_min);
- I max = level::compute(if_ima, acu_max);
+ I min = level::compute(acu_min, if_ima);
+ I max = level::compute(acu_max, if_ima);
mln_assertion(min == real_min2);
mln_assertion(max == real_max2);
}
@@ -176,8 +176,8 @@
accu::min_<I> acu_min;
accu::max_<I> acu_max;
- I min = level::compute(ima, acu_min);
- I max = level::compute(ima, acu_max);
+ I min = level::compute(acu_min, ima);
+ I max = level::compute(acu_max, ima);
mln_assertion(min == real_min);
mln_assertion(max == real_max);
@@ -207,8 +207,8 @@
accu::min_<I> acu_min;
accu::max_<I> acu_max;
- I min = level::compute(ima, acu_min);
- I max = level::compute(ima, acu_max);
+ I min = level::compute(acu_min, ima);
+ I max = level::compute(acu_max, ima);
mln_assertion(min == real_min);
mln_assertion(max == real_max);
Index: tests/level/compute.cc
--- tests/level/compute.cc (revision 2546)
+++ tests/level/compute.cc (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,11 +43,13 @@
const unsigned size = 200;
image2d<int> ima(size, size);
- accu::min_<int> acu_min;
- accu::max_<int> acu_max;
debug::iota(ima);
- int min = level::compute(ima, acu_min);
- int max = level::compute(ima, acu_max);
+
+ accu::min_<int> m;
+ int min = level::compute(m, ima);
mln_assertion(min == 1);
+
+ accu::max_<int> M;
+ int max = level::compute(M, ima);
mln_assertion(max == 40000);
}
Index: tests/level/update.cc
--- tests/level/update.cc (revision 2546)
+++ tests/level/update.cc (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
@@ -25,13 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level/take.cc
+/*! \file tests/level/update.cc
*
- * \brief Tests on mln::level::take.
+ * \brief Tests on mln::level::update.
*/
#include <mln/core/image/image2d.hh>
-#include <mln/level/take.hh>
+#include <mln/level/update.hh>
#include <mln/level/compare.hh>
#include <mln/debug/iota.hh>
#include <mln/accu/min.hh>
@@ -44,14 +44,13 @@
const unsigned size = 200;
image2d<int> ima(size, size);
- accu::min_<int> acu_min;
- accu::max_<int> acu_max;
+ accu::min_<int> m;
+ accu::max_<int> M;
debug::iota(ima);
- level::take(ima, acu_min);
- level::take(ima, acu_max);
-
- mln_assertion(acu_min.to_result() == 1);
- mln_assertion(acu_max.to_result() == 40000);
+ level::update(m, ima);
+ level::update(M, ima);
+ mln_assertion(m == 1);
+ mln_assertion(M == 40000);
}
Index: tests/level/Makefile.am
--- tests/level/Makefile.am (revision 2546)
+++ tests/level/Makefile.am (working copy)
@@ -25,8 +25,8 @@
sort_psites \
sort_psites_full \
stretch \
- take \
- transform
+ transform \
+ update
abs_SOURCES = abs.cc
all_headers_SOURCES = all_headers.cc
@@ -47,8 +47,8 @@
saturate_SOURCES = saturate.cc
sort_psites_SOURCES = sort_psites.cc
stretch_SOURCES = stretch.cc
-take_SOURCES = take.cc
transform_SOURCES = transform.cc
+update_SOURCES = update.cc
# Lengthy tests.
sort_psites_full_SOURCES = sort_psites_full.cc
Index: tests/estim/Makefile.am
--- tests/estim/Makefile.am (revision 2546)
+++ tests/estim/Makefile.am (working copy)
@@ -3,8 +3,10 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- mean
+ mean \
+ min_max
mean_SOURCES = mean.cc
+min_max_SOURCES = min_max.cc
TESTS = $(check_PROGRAMS)
Index: tests/estim/min_max.cc
--- tests/estim/min_max.cc (revision 0)
+++ tests/estim/min_max.cc (revision 0)
@@ -0,0 +1,52 @@
+// 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.
+
+/*! \file tests/estim/min_max.cc
+ *
+ * \brief Tests on mln::estim::min_max.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/estim/min_max.hh>
+#include <mln/debug/iota.hh>
+#include <mln/accu/min.hh>
+#include <mln/accu/max.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned size = 200;
+ image2d<int> ima(size, size);
+ debug::iota(ima);
+
+ int m, M;
+ estim::min_max(ima, m, M);
+ mln_assertion(m == 1);
+ mln_assertion(M == 40000);
+}
Index: mln/level/update.hh
--- mln/level/update.hh (revision 2546)
+++ mln/level/update.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
@@ -25,19 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_LEVEL_TAKE_HH
-# define MLN_LEVEL_TAKE_HH
+#ifndef MLN_LEVEL_UPDATE_HH
+# define MLN_LEVEL_UPDATE_HH
-/*! \file mln/level/take.hh
+/*! \file mln/level/update.hh
*
- * \brief Make an accumulator take image pixel values.
+ * \brief Update an accumulator with image pixel values.
*/
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+
-// Specializations are in:
-# include <mln/level/take.spe.hh>
namespace mln
{
@@ -45,60 +45,143 @@
namespace level
{
- /*! Make an accumulator take the values of the image \p input.
+ /*! Update an accumulator with the pixel values of the image \p input.
*
+ * \param[in] a The accumulator.
* \param[in] input The input image.
- * \param[in,out] a The accumulator.
- *
- * This routine runs: \n
- * for all p of \p input, \p a.take( \p input(p) ) \n
- *
- * \pre \p input has to be initialized.
- *
- * \warning This routine does not perform a.init().
+ * \return The accumulator result.
*/
template <typename A, typename I>
- void take(const Image<I>& input, Accumulator<A>& a);
+ mln_result(A)
+ update(Accumulator<A>& a, const Image<I>& input);
+
# ifndef MLN_INCLUDE_ONLY
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename A, typename I>
+ inline
+ void
+ update_tests(Accumulator<A>& a_, const Image<I>& input_)
+ {
+ A& a = exact(a_);
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+ // sizeof(a.take(mln_value(I)()));
+
+ (void) a;
+ (void) input;
+ }
+
+ } // end of namespace internal
+
+
+
+ // Implementations.
+
namespace impl
{
namespace generic
{
+
template <typename A, typename I>
- inline
- void take_(const I& input, A& a)
+ mln_result(A)
+ update(Accumulator<A>& a_, const Image<I>& input_)
{
- trace::entering("level::impl::generic::take");
+ trace::entering("level::impl::generic::update");
+
+ A& a = exact(a_);
+ const I& input = exact(input_);
+ internal::update_tests(a, input);
mln_piter(I) p(input.domain());
for_all(p)
a.take(input(p));
- trace::exiting("level::impl::generic::take");
+ trace::exiting("level::impl::generic::update");
+ return a.to_result();
}
} // end of namespace mln::level::impl::generic
+
+ template <typename A, typename I>
+ mln_result(A)
+ update_fastest(Accumulator<A>& a_, const Image<I>& input_)
+ {
+ trace::entering("level::impl::update_fastest");
+
+ A& a = exact(a_);
+ const I& input = exact(input_);
+ internal::update_tests(a, input);
+
+ mln_pixter(const I) pxl(input);
+ for_all(pxl)
+ a.take(pxl.val());
+
+ trace::exiting("level::impl::update_fastest");
+ return a.to_result();
+ }
+
+
} // end of namespace mln::level::impl
- // Facade.
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename A, typename I>
+ mln_result(A)
+ update_dispatch(trait::image::speed::any,
+ Accumulator<A>& a, const Image<I>& input)
+ {
+ return impl::generic::update(a, input);
+ }
+
+ template <typename A, typename I>
+ mln_result(A)
+ update_dispatch(trait::image::speed::fastest,
+ Accumulator<A>& a, const Image<I>& input)
+ {
+ return impl::update_fastest(a, input);
+ }
+
+ template <typename A, typename I>
+ mln_result(A)
+ update_dispatch(Accumulator<A>& a, const Image<I>& input)
+ {
+ return update_dispatch(mln_trait_image_speed(I)(),
+ a, input);
+ }
+
+ } // end of namespace internal
+
+
+
+ // Facades.
template <typename A, typename I>
inline
- void take(const Image<I>& input, Accumulator<A>& a)
+ mln_result(A)
+ update(Accumulator<A>& a, const Image<I>& input)
{
- trace::entering("level::take");
+ trace::entering("level::update");
- mln_precondition(exact(input).has_data());
- impl::take_(mln_trait_image_speed(I)(), exact(input),
- exact(a));
+ internal::update_tests(a, input);
+ mln_result(A) r = internal::update_dispatch(a, input);
- trace::exiting("level::take");
+ trace::exiting("level::update");
+ return r;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -108,4 +191,4 @@
} // end of namespace mln
-#endif // ! MLN_LEVEL_TAKE_HH
+#endif // ! MLN_LEVEL_UPDATE_HH
Index: mln/level/compute.hh
--- mln/level/compute.hh (revision 2546)
+++ mln/level/compute.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,9 +33,9 @@
* \brief Compute an accumulator onto image pixel values.
*/
+# include <mln/core/concept/accumulator.hh>
+# include <mln/core/concept/image.hh>
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/level/take.hh>
-# include <mln/metal/is_a.hh>
@@ -47,60 +47,162 @@
/*! Compute an accumulator onto the pixel values of the image \p input.
*
+ * \param[in] a An accumulator.
* \param[in] input The input image.
- * \param[in] a The accumulator.
* \return The accumulator result.
- *
- * This routine runs: \n
- * tmp = \p a \n
- * tmp.init() \n
- * level::take(\p input, tmp) \n
- * return tmp.to_result() \n
*/
- template <typename I, typename A>
+ template <typename A, typename I>
mln_result(A)
- compute(const Image<I>& input, const Accumulator<A>& a);
+ compute(const Accumulator<A>& a, const Image<I>& input);
+
+ /*! Compute an accumulator onto the pixel values of the image \p input.
+ *
+ * \param[in] a A meta-accumulator.
+ * \param[in] input The input image.
+ * \return The accumulator result.
+ */
template <typename A, typename I>
mln_accu_with(A, mln_value(I))::result
- compute(const Image<I>& input);
+ compute(const Meta_Accumulator<A>& a, const Image<I>& input);
+
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename A>
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename A, typename I>
inline
+ void
+ compute_tests(const Accumulator<A>& a_, const Image<I>& input_)
+ {
+ const A& a = exact(a_);
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+ // sizeof(a.take(mln_value(I)()));
+
+ (void) a;
+ (void) input;
+ }
+
+ } // end of namespace internal
+
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename A, typename I>
mln_result(A)
- compute(const Image<I>& input, const Accumulator<A>& a_)
+ compute(const Accumulator<A>& a_, const Image<I>& input_)
{
- trace::entering("level::compute");
+ trace::entering("level::impl::generic::compute");
+
+ A a = exact(a_);
+ const I& input = exact(input_);
+ internal::compute_tests(a, input);
- mln_precondition(exact(input).has_data());
- A a = exact(a_); // Cpy.
a.init();
- level::take(input, a);
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ a.take(input(p));
- trace::exiting("level::compute");
+ trace::exiting("level::impl::generic::compute");
return a.to_result();
}
+ } // end of namespace mln::level::impl::generic
+
+
template <typename A, typename I>
- inline
mln_result(A)
- compute(const Image<I>& input)
+ compute_fastest(const Accumulator<A>& a_, const Image<I>& input_)
{
- mln_precondition(exact(input).has_data());
- return level::compute(input, A());
+ trace::entering("level::impl::compute_fastest");
+
+ A a = exact(a_);
+ const I& input = exact(input_);
+ internal::compute_tests(a, input);
+
+ a.init();
+ mln_pixter(const I) pxl(input);
+ for_all(pxl)
+ a.take(pxl.val());
+
+ trace::exiting("level::impl::compute_fastest");
+ return a.to_result();
+ }
+
+
+ } // end of namespace mln::level::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename A, typename I>
+ mln_result(A)
+ compute_dispatch(trait::image::speed::any,
+ const Accumulator<A>& a, const Image<I>& input)
+ {
+ return impl::generic::compute(a, input);
+ }
+
+ template <typename A, typename I>
+ mln_result(A)
+ compute_dispatch(trait::image::speed::fastest,
+ const Accumulator<A>& a, const Image<I>& input)
+ {
+ return impl::compute_fastest(a, input);
}
template <typename A, typename I>
+ mln_result(A)
+ compute_dispatch(const Accumulator<A>& a, const Image<I>& input)
+ {
+ return compute_dispatch(mln_trait_image_speed(I)(),
+ a, input);
+ }
+
+ } // end of namespace internal
+
+
+
+ // Facades.
+
+ template <typename A, typename I>
inline
+ mln_result(A)
+ compute(const Accumulator<A>& a, const Image<I>& input)
+ {
+ trace::entering("level::compute");
+
+ internal::compute_tests(a, input);
+ mln_result(A) r = internal::compute_dispatch(a, input);
+
+ trace::exiting("level::compute");
+ return r;
+ }
+
+ template <typename A, typename I>
mln_accu_with(A, mln_value(I))::result
- compute(const Image<I>& input)
+ compute(const Meta_Accumulator<A>&, const Image<I>& input)
{
- mlc_is_a(A, Meta_Accumulator)::check();
- return compute(input,
- mln_accu_with(A, mln_value(I))());
+ mln_accu_with(A, mln_value(I)) accu;
+ return compute(accu, input); // Call the previous version.
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 2546)
+++ mln/accu/min.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
@@ -74,9 +74,12 @@
template <typename I> struct min_< util::pix<I> >;
- /*!
- * \brief Meta accumulator for min.
- */
+
+ namespace meta
+ {
+
+ /// Meta accumulator for min.
+
struct min : public Meta_Accumulator< min >
{
template <typename T>
@@ -86,8 +89,7 @@
};
};
-
-
+ } // end of namespace mln::accu::meta
Index: mln/accu/max.hh
--- mln/accu/max.hh (revision 2546)
+++ mln/accu/max.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
@@ -74,9 +74,11 @@
template <typename I> struct max_< util::pix<I> >;
- /*!
- * \brief Meta accumulator for max.
- */
+ namespace meta
+ {
+
+ /// Meta accumulator for max.
+
struct max : public Meta_Accumulator< max >
{
template <typename T>
@@ -86,6 +88,7 @@
};
};
+ } // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
Index: mln/accu/min_max.hh
--- mln/accu/min_max.hh (revision 2546)
+++ mln/accu/min_max.hh (working copy)
@@ -63,9 +63,14 @@
template <typename I> struct min_max_< util::pix<I> >;
+ namespace meta
+ {
+
// FIXME: Doc!
typedef pair<min,max> min_max;
+ } // end of namespace mln::accu::meta
+
} // end of namespace mln::accu
Index: mln/accu/pair.hh
--- mln/accu/pair.hh (revision 2546)
+++ mln/accu/pair.hh (working copy)
@@ -84,9 +84,11 @@
A2 a2_;
};
- /*!
- * \brief Meta accumulator for pair.
- */
+
+ namespace meta
+ {
+
+ /// Meta accumulator for pair.
template <typename A1, typename A2>
struct pair : public Meta_Accumulator< pair<A1,A2> >
{
@@ -99,6 +101,8 @@
};
};
+ } // end of namespace mln::accu::meta
+
# ifndef MLN_INCLUDE_ONLY
Index: mln/accu/sum.hh
--- mln/accu/sum.hh (revision 2546)
+++ mln/accu/sum.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
@@ -79,10 +79,10 @@
template <typename I, typename S>
struct sum_< util::pix<I>, S >;
+ namespace meta
+ {
- /*!
- * \brief Meta accumulator for sum.
- */
+ /// Meta accumulator for sum.
struct sum : public Meta_Accumulator< sum >
{
template <typename T, typename S = mln_sum(T)>
@@ -92,6 +92,7 @@
};
};
+ } // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
Index: mln/accu/mean.hh
--- mln/accu/mean.hh (revision 2546)
+++ mln/accu/mean.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
@@ -83,9 +83,10 @@
struct mean_< util::pix<I>, S,M >;
- /*!
- * \brief Meta accumulator for mean.
- */
+ namespace meta
+ {
+
+ /// Meta accumulator for mean.
struct mean : public Meta_Accumulator< mean >
{
template < typename T,
@@ -97,6 +98,8 @@
};
};
+ } // end of namespace mln::accu::meta
+
# ifndef MLN_INCLUDE_ONLY
Index: mln/estim/sum.hh
--- mln/estim/sum.hh (revision 2546)
+++ mln/estim/sum.hh (working copy)
@@ -70,7 +70,7 @@
mln_sum(mln_value(I)) sum(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return level::compute<accu::sum, I>(input);
+ return level::compute(accu::meta::sum(), input);
}
template <typename I, typename S>
@@ -78,8 +78,8 @@
void sum(const Image<I>& input, S& result)
{
mln_precondition(exact(input).has_data());
- typedef accu::sum_<mln_value(I), S> A;
- result = level::compute(input, A());
+ accu::sum_<mln_value(I), S> a;
+ result = level::compute(a, input);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/estim/min_max.hh
--- mln/estim/min_max.hh (revision 2546)
+++ mln/estim/min_max.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
@@ -31,6 +31,8 @@
/*! \file mln/estim/min_max.hh
*
* \brief Compute the min and max pixel values of an image.
+ *
+ * \todo Overload while returning an std::pair.
*/
# include <mln/accu/min_max.hh>
@@ -62,8 +64,8 @@
mln_value(I)& min, mln_value(I)& max)
{
mln_precondition(exact(input).has_data());
- typedef accu::min_max_<mln_value(I)> A;
- mln_result(A) mm = level::compute<A>(input);
+ typedef mln_value(I) V;
+ std::pair<V, V> mm = level::compute(accu::meta::min_max(), input);
min = mm.first;
max = mm.second;
}
Index: mln/estim/mean.hh
--- mln/estim/mean.hh (revision 2546)
+++ mln/estim/mean.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
@@ -71,7 +71,7 @@
mln_sum(mln_value(I)) mean(const Image<I>& input)
{
mln_precondition(exact(input).has_data());
- return level::compute<accu::mean>(input);
+ return level::compute(accu::meta::mean(), input);
}
template <typename S, typename I, typename M>
@@ -79,8 +79,8 @@
void mean(const Image<I>& input, M& result)
{
mln_precondition(exact(input).has_data());
- typedef accu::mean_<mln_value(I), S, M> A;
- result = level::compute(input, A());
+ accu::mean_<mln_value(I), S, M> a;
+ result = level::compute(a, input);
}
# endif // ! MLN_INCLUDE_ONLY
1
0
---
ChangeLog | 6 ++
milena/sandbox/scribo/remove_tables.cc | 111 ++++++++++++++++++++++++++++++++
2 files changed, 117 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/scribo/remove_tables.cc
diff --git a/ChangeLog b/ChangeLog
index 2757d06..2bf6a2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-13-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * milena/sandbox/scribo/remove_tables.cc:
+ New small example to remove table borders in a document such as a
+ bill.
+
2008-10-07 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix most of the doxygen warnings.
diff --git a/milena/sandbox/scribo/remove_tables.cc b/milena/sandbox/scribo/remove_tables.cc
new file mode 100644
index 0000000..0ee0528
--- /dev/null
+++ b/milena/sandbox/scribo/remove_tables.cc
@@ -0,0 +1,111 @@
+// 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.
+
+/*! \file doc/examples/hit_or_miss.cc
+ *
+ * \brief Test on mln::morpho::hit_or_miss.
+ */
+
+# include <mln/core/image/image2d.hh>
+
+# include <mln/core/image/image_if.hh>
+# include <mln/core/image/sub_image.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/var.hh>
+# include <mln/core/site_set/p_vaccess.hh>
+
+# include <mln/binarization/threshold.hh>
+# include <mln/morpho/hit_or_miss.hh>
+# include <mln/level/fill.hh>
+# include <mln/border/fill.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/io/pgm/load.hh>
+# include <mln/io/pbm/save.hh>
+# include <mln/io/pgm/save.hh>
+# include <mln/debug/println.hh>
+# include <mln/morpho/opening.hh>
+# include <mln/trait/value_.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/level/paste.hh>
+# include <mln/labeling/blobs.hh>
+# include <mln/level/fill.hh>
+# include <mln/pw/all.hh>
+# include <mln/convert/to_fun.hh>
+# include <mln/geom/bbox.hh>
+
+void clean_lines(mln::image2d<bool>& in,
+ const mln::image2d<bool>& ima,
+ unsigned bbox_larger)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ int_u8 nlabels;
+ image2d<int_u8> lbl = labeling::blobs(ima, c4(), nlabels);
+
+ for (unsigned i = nlabels; i > 0; --i)
+ {
+ level::paste(pw::cst(false)
+ | geom::bbox(lbl | (pw::value(lbl) == pw::cst(i))),//.to_larger(bbox_larger),
+ in);
+ }
+}
+
+int main(int argc, char*argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc < 2)
+ {
+ std::cout << argv[0] << " <image.pgm> <h> <w>" << std::endl;
+ return 1;
+ }
+
+ image2d<bool> in;
+ io::pbm::load(in, argv[1]);
+
+ unsigned h = atoi(argv[2]);
+ unsigned w = atoi(argv[3]);
+ unsigned n = atoi(argv[4]);
+
+ // Lignes verticales
+ win::rectangle2d vwin(h, w);
+ image2d<bool> vout = morpho::opening(in, vwin);
+ io::pbm::save(vout, "./vout.pbm");
+ clean_lines(in, vout, n);
+
+ // Lignes horizontales
+ win::rectangle2d hwin(w, h);
+ image2d<bool> hout = morpho::opening(in, hwin);
+ io::pbm::save(hout, "./hout.pbm");
+ clean_lines(in, hout, n);
+
+ io::pbm::save(in, "./outt.pbm");
+
+ return 0;
+}
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Update registration.
* mln/core/site_set/box.hh (larger_than): Add.
* mln/math/jacobi.hh: Add jacobi eigen vector extraction method.
* mln/registration/registration.hh: Minor fix.
* mln/registration/icp.hh: Fix.
* mln/registration/get_rtransf.hh: Add match function.
core/site_set/box.hh | 22 ++++++
math/jacobi.hh | 155 +++++++++++++++++++++++++++++++++++++++++++
registration/get_rtransf.hh | 124 ++++++++++++++++++++++++++++++++++
registration/icp.hh | 54 +++++++++++---
registration/registration.hh | 8 +-
5 files changed, 345 insertions(+), 18 deletions(-)
Index: mln/core/site_set/box.hh
--- mln/core/site_set/box.hh (revision 2544)
+++ mln/core/site_set/box.hh (working copy)
@@ -165,6 +165,13 @@
template <typename P>
std::ostream& operator<<(std::ostream& ostr, const box<P>& b);
+ // Procedures
+
+ /// Return the minimum box including box \p a and box \b
+ template <typename P>
+ inline
+ box<P>
+ larger_than(const box<P> a, const box<P> b);
# ifndef MLN_INCLUDE_ONLY
@@ -287,6 +294,21 @@
mln_postcondition(is_valid());
}
+ template <typename P>
+ inline
+ box<P>
+ larger_than(const box<P> a, const box<P> b)
+ {
+ P pmin,pmax;
+
+ for (unsigned i = 0; i < P::dim; i++)
+ {
+ pmin[i] = (a.pmin()[i] < b.pmin()[i]) ? a.pmin()[i] : b.pmin()[i];
+ pmax[i] = (a.pmax()[i] > b.pmax()[i]) ? a.pmax()[i] : b.pmax()[i];
+ }
+
+ return box<P>(pmin, pmax);
+ }
template <typename P>
inline
Index: mln/math/jacobi.hh
--- mln/math/jacobi.hh (revision 0)
+++ mln/math/jacobi.hh (revision 0)
@@ -0,0 +1,155 @@
+// 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_MATH_JACOBI_HH
+# define MLN_MATH_JACOBI_HH
+
+# include <mln/algebra/quat.hh>
+# include <mln/algebra/mat.hh>
+
+// from num. rec. in C
+// FIXME: what about numrec licence?
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ algebra::quat jacobi(algebra::mat < 4, 4, float >a);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // FIXME: nD ?
+#define rotateJacobi(a,i,j,k,l) g=a(i,j);h=a(k,l);a(i,j)=g-s*(h+g*tau); \
+ a(k,l)=h+s*(g-h*tau)
+
+ algebra::quat jacobi(algebra::mat < 4, 4, float >a)
+ {
+ float dd, d[4];
+ algebra::mat < 4, 4, float >v(literal::zero);
+ int j, iq, ip, i = 0;
+ float tresh, theta, tau, t, sm, s, h, g, c, b[4], z[4];
+ for (ip = 0; ip < 4; ip++)
+ {
+ for (iq = 0; iq < 4; iq++)
+ v(ip, iq) = 0.0;
+ v(ip, ip) = 1.0;
+ }
+ for (ip = 0; ip < 4; ip++)
+ {
+ b[ip] = d[ip] = a(ip, ip);
+ z[ip] = 0.0;
+ }
+ while (1)
+ {
+ sm = 0.0;
+ for (ip = 0; ip < 3; ip++)
+ {
+ for (iq = ip + 1; iq < 4; iq++)
+ sm += fabs(a(ip, iq));
+ }
+ if (sm < 1e-12)
+ { // 1e-12
+ dd = d[0];
+ iq = 0;
+ for (ip = 1; ip < 4; ip++)
+ if (d[ip] > dd)
+ {
+ iq = ip;
+ dd = d[ip];
+ }
+ algebra::quat q(v(0, iq), v(1, iq), v(2, iq), v(3, iq));
+ q.set_unit();
+ return q;
+ }
+ if (i < 4)
+ {
+ i++;
+ tresh = 0.0125 * sm;
+ }
+ else
+ tresh = 0.0;
+ for (ip = 0; ip < 3; ip++)
+ {
+ for (iq = ip + 1; iq < 4; iq++)
+ {
+ g = 100.0 * fabs(a(ip, iq));
+ if (i > 4 && (float)(fabs(d[ip])+g) ==
+ (float)fabs(d[ip])
+ && (float)(fabs(d[iq])+g) == (float)fabs(d[iq]))
+ a(ip, iq) = 0.0;
+ else if (fabs(a(ip, iq)) > tresh)
+ {
+ h = d[iq] - d[ip];
+ if ((float)(fabs(h)+g) == (float)fabs(h)) // unsafe?
+ t = (a(ip, iq)) / h;
+ else
+ {
+ theta = 0.5 * h / (a(ip, iq));
+ t = 1.0 / (fabs(theta) + sqrt(1.0 +
+ theta * theta));
+ if (theta < 0.0)
+ t = -t;
+ }
+ c = 1.0 / sqrt(1 + t * t);
+ s = t * c;
+ tau = s / (1.0 + c);
+ h = t * a(ip, iq);
+ z[ip] -= h;
+ z[iq] += h;
+ d[ip] -= h;
+ d[iq] += h;
+ a(ip, iq) = 0.0;
+ for (j = 0; j <= ip - 1; j++)
+ rotateJacobi(a, j, ip, j, iq);
+ for (j = ip + 1; j <= iq - 1; j++)
+ rotateJacobi(a, ip, j, j, iq);
+ for (j = iq + 1; j < 4; j++)
+ rotateJacobi(a, ip, j, iq, j);
+ for (j = 0; j < 4; j++)
+ rotateJacobi(v, j, ip, j, iq);
+ }
+ }
+ }
+ for (ip = 0; ip < 4; ip++)
+ {
+ b[ip] += z[ip];
+ d[ip] = b[ip];
+ z[ip] = 0.0;
+ }
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace math
+
+} // end of namespace mln
+
+#endif /* MLN_MATH_JACOBI_HH */
+
Index: mln/registration/registration.hh
--- mln/registration/registration.hh (revision 2544)
+++ mln/registration/registration.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/registration/icp.hh>
+# include <mln/fun/x2x/all.hh>
# include <mln/fun/x2p/closest_point.hh>
# include <mln/core/image/lazy_image.hh>
@@ -43,8 +44,7 @@
namespace registration
{
-
- using namespace fun::x2x;
+ using namespace mln::fun::x2x;
/*! Register an image \p cloud over the image \p surface.
*/
@@ -74,7 +74,7 @@
//working box
const box<mln_psite(I)> working_box =
- enlarge(bigger(geom::bbox(c), geom::bbox(x)), 100);
+ larger_than(geom::bbox(c), geom::bbox(x)).to_larger(100);
//make a lazy_image map via function closest_point
fun::x2p::closest_point<mln_psite(I)> fun(x, working_box);
@@ -83,7 +83,7 @@
//run registration
- registration::icp(c, map, qk, c.nsites(), 1e-3);
+ return registration::icp(c, map, 1e-3);
}
Index: mln/registration/icp.hh
--- mln/registration/icp.hh (revision 2544)
+++ mln/registration/icp.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/fun/x2x/all.hh>
# include <mln/fun/x2v/all.hh>
+# include <mln/registration/get_rtransf.hh>
namespace mln
{
@@ -95,7 +96,7 @@
*/
template <typename P, typename M>
inline
- composed<rotation<2u, float>, translation<2u, float> >
+ composed<rotation<P::dim, float>, translation<P::dim, float> >
icp(const p_array<P>& c, const M& map,
const float epsilon = 1e-3);
@@ -117,10 +118,32 @@
namespace impl
{
+ // FIXME: Move elsewhere
+ template <typename P>
+ P center(const p_array<P>& a)
+ {
+ algebra::vec<P::dim,float> c(literal::zero);
+ for (unsigned i = 0; i < a.nsites(); ++i)
+ c += convert::to< algebra::vec<P::dim,float> > (a[i]);
+
+ return algebra::to_point<P>(c / a.nsites());
+ }
+
+ // FIXME: Make use of level::apply
+ template <typename P, typename F>
+ void apply(F& f,
+ const p_array<P>& a,
+ p_array<P>& b)
+ {
+ for (unsigned i = 0; i < a.nsites(); i++)
+ b[i] = f(a[i]);
+ }
+
+
template <typename P, typename M, typename T>
inline
void
- icp_(const p_array<P>& c,
+ icp_(const p_array<P>& c_,
const unsigned c_length,
const M& map,
T& qk,
@@ -132,28 +155,32 @@
util::buffer<3,float> buf_dk;
float d_k = 10000;
- p_array<P> Ck(c);
- algebra::vec<P::dim,float> mu_C = center(c, c_length), mu_Xk;
+ //work on a reduced version of c_
+ p_array<P> c = c_;
+ c.hook_std_vector_().resize(c_length);
+
+ p_array<P> ck(c);
+ algebra::vec<P::dim,float> mu_c = center(c);
buf_qk.store(qk);
- qk.apply_on(c, Ck, c_length);
+ apply(qk, c, ck);
unsigned int k = 0;
do {
buf_dk.store(d_k);
//compute qk
- qk = match(c, mu_C, Ck, map, c_length);
+ qk = get_rtransf(c, mu_c, ck, map);
buf_qk.store(qk);
//Ck+1 = qk(c)
- qk.apply_on(c, Ck, c_length);
+ apply(qk, c, ck);
// d_k = d(Yk, Pk+1)
// = d(closest(qk-1(P)), qk(P))
- d_k = rms(c, map, c_length, buf_qk[1], qk);
+ d_k = rms(c, map, buf_qk[1], qk);
k++;
} while ((qk - buf_qk[1]).sqr_norm() / qk.sqr_norm() > epsilon);
@@ -164,15 +191,14 @@
} // end of namespace mln::registration::impl
- template <typename P, typename M, typename T>
+ template <typename P, typename M>
inline
- T
- icp(const p_array<P>& c,
- const M& map,
+ composed<rotation<P::dim, float>, translation<P::dim, float> >
+ icp(const p_array<P>& c, const M& map,
const float epsilon = 1e-3)
{
- T qk;
- impl::icp_(c, map, qk, c.length(), epsilon);
+ composed<rotation<P::dim, float>, translation<P::dim, float> > qk;
+ impl::icp_(c, c.nsites(),map, qk, epsilon);
return qk;
}
Index: mln/registration/get_rtransf.hh
--- mln/registration/get_rtransf.hh (revision 0)
+++ mln/registration/get_rtransf.hh (revision 0)
@@ -0,0 +1,124 @@
+// 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_REGISTRATION_GET_RTRANSF_HH
+# define MLN_REGISTRATION_GET_RTRANSF_HH
+
+# include <mln/fun/x2x/all.hh>
+# include <mln/algebra/quat.hh>
+# include <mln/math/jacobi.hh>
+
+namespace mln
+{
+
+ namespace registration
+ {
+
+ using namespace fun::x2x;
+
+ template <typename P, typename M>
+ composed<rotation<P::dim, float>, translation<P::dim, float> >
+ get_rtransf(const p_array<P>& C,
+ const algebra::vec<P::dim,float>& mu_C,
+ const p_array<P>& ck,
+ const M& map);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename P, typename M>
+ composed<rotation<P::dim, float>, translation<P::dim, float> >
+ get_rtransf(const p_array<P>& c,
+ const algebra::vec<P::dim,float>& mu_c,
+ const p_array<P>& ck,
+ const M& map)
+ {
+ //mu_xk = center map(Ck)
+ algebra::vec<P::dim,float> mu_xk(literal::zero);
+ for (unsigned i = 0; i < c.nsites(); ++i)
+ mu_xk += convert::to< algebra::vec<P::dim,float> >(map(ck[i]));
+ mu_xk /= c.nsites();
+
+ // FIXME: Make use of a cross_covariance accu (maybe not because of map(ck[i]))
+ // qR
+ algebra::mat<P::dim,P::dim,float> Mk(literal::zero);
+ for (unsigned i = 0; i < c.nsites(); ++i)
+ {
+ algebra::vec<P::dim,float> ci = c[i];
+ algebra::vec<P::dim,float> xki = map(ck[i]);
+ Mk += make::mat(ci - mu_c) * trans(make::mat(xki - mu_xk));
+ }
+ Mk /= c.nsites();
+
+ algebra::vec<3,float> a;
+ a[0] = Mk(1,2) - Mk(2,1);
+ a[1] = Mk(2,0) - Mk(0,2);
+ a[2] = Mk(0,1) - Mk(1,0);
+
+ algebra::mat<4,4,float> Qk(literal::zero);
+ float t = tr(Mk);
+
+ Qk(0,0) = t;
+ for (int i = 1; i < 4; i++)
+ {
+ Qk(i,0) = a[i - 1];
+ Qk(0,i) = a[i - 1];
+ for (int j = 1; j < 4; j++)
+ if (i == j)
+ Qk(i,j) = 2 * Mk(i - 1,i - 1) - t;
+ }
+
+ Qk(1,2) = Mk(0,1) + Mk(1,0);
+ Qk(2,1) = Mk(0,1) + Mk(1,0);
+
+ Qk(1,3) = Mk(0,2) + Mk(2,0);
+ Qk(3,1) = Mk(0,2) + Mk(2,0);
+
+ Qk(2,3) = Mk(1,2) + Mk(2,1);
+ Qk(3,2) = Mk(1,2) + Mk(2,1);
+
+ algebra::quat qR(literal::zero);
+ qR = math::jacobi(Qk);
+
+ // qT
+ const algebra::vec<P::dim,float> qT = mu_xk - rotate(qR, mu_c);
+
+ rotation<P::dim, float> tqR(qR);
+ translation<P::dim, float> tqT(qT);
+ return compose(tqR,tqT);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace registration
+
+} // end of namespace mln
+
+#endif /* MLN_REGISTRATION_GET_RTRANSF_HH */
+
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Update Registration.
* mln/fun/x2v/all.hh: Add all header.
* mln/fun/x2x/all.hh: Fix includes.
* mln/fun/x2p/closest_point.hh: Fix g++4.3 error.
* mln/registration/registration.hh: Fix namespace use.
* mln/registration/icp.hh: Fix namespace use.
fun/x2p/closest_point.hh | 13 ++++-----
fun/x2v/all.hh | 61
+++++++++++++++++++++++++++++++++++++++++++
fun/x2x/all.hh | 10 ++-----
registration/icp.hh | 3 +-
registration/registration.hh | 4 +-
5 files changed, 75 insertions(+), 16 deletions(-)
Index: mln/fun/x2v/all.hh
--- mln/fun/x2v/all.hh (revision 0)
+++ mln/fun/x2v/all.hh (revision 0)
@@ -0,0 +1,61 @@
+// 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_X2V_ALL_HH
+# define MLN_FUN_X2V_ALL_HH
+
+/*! \file mln/fun/x2v/all.hh
+ *
+ * \brief File that includes all functions from vector to value.
+ */
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// Namespace of functions from vector to value.
+ namespace x2v
+ {
+
+ /// Internal namespace of functions form vector to vector.
+ namespace internal
+ {
+ }
+ }
+ }
+
+}
+
+
+# include <mln/fun/x2v/linear.hh>
+# include <mln/fun/x2v/bilinear.hh>
+# include <mln/fun/x2v/nneighbor.hh>
+
+#endif // ! MLN_FUN_X2V_ALL_HH
Index: mln/fun/x2x/all.hh
--- mln/fun/x2x/all.hh (revision 2542)
+++ mln/fun/x2x/all.hh (working copy)
@@ -54,13 +54,9 @@
}
-# include <mln/fun/x2x/geom/composed.hh>
-# include <mln/fun/x2x/geom/rotation.hh>
-# include <mln/fun/x2x/geom/translation.hh>
-
-# include <mln/fun/x2x/interpol/linear.hh>
-# include <mln/fun/x2x/interpol/bilinear.hh>
-
+# include <mln/fun/x2x/composed.hh>
+# include <mln/fun/x2x/rotation.hh>
+# include <mln/fun/x2x/translation.hh>
#endif // ! MLN_FUN_X2X_ALL_HH
Index: mln/fun/x2p/closest_point.hh
--- mln/fun/x2p/closest_point.hh (revision 2542)
+++ mln/fun/x2p/closest_point.hh (working copy)
@@ -31,6 +31,7 @@
# include <mln/algebra/vec.hh>
# include <mln/norm/l2.hh>
+
namespace mln
{
@@ -44,25 +45,25 @@
template <typename P>
struct closest_point
{
- typedef algebra::vec<P::dim, float> input;
+ typedef const algebra::vec<P::dim, float>& input;
typedef P result;
closest_point(const p_array<P>& X, const box<P>& box)
- : X(X), box(box)
+ : X(X), box_(box)
, log_functor_call(0)
{ }
result
//inline
- operator () (const input& Ck) const
+ operator () (const algebra::vec<P::dim, float>& Ck) const
{
++log_functor_call;
algebra::vec<P::dim,float> Cki = Ck;
algebra::vec<P::dim,float> best_x = X[0];
float best_d = norm::l2(Cki - best_x);
- for (size_t j = 1; j < X.nsites(); ++j)
+ for (unsigned j = 1; j < X.nsites(); ++j)
{
algebra::vec<P::dim,float> Xj = X[j];
float d = norm::l2(Cki - Xj);
@@ -77,11 +78,11 @@
const box<P>& domain() const
{
- return box;
+ return box_;
}
+ const box<P> box_;
const p_array<P>& X;
- const box<P> box;
// log call to the functor
mutable unsigned log_functor_call;
Index: mln/registration/registration.hh
--- mln/registration/registration.hh (revision 2542)
+++ mln/registration/registration.hh (working copy)
@@ -44,7 +44,7 @@
{
- using namespace fun::x2x::geom;
+ using namespace fun::x2x;
/*! Register an image \p cloud over the image \p surface.
*/
@@ -70,7 +70,7 @@
p_array<mln_psite(J)> x = convert::to< p_array<mln_psite(I)>
>(surface);
//init rigid transform qk
- composed< rotation<I::P::dim, float>, translation<I::P::dim,
float> > qk;
+ composed< rotation<I::psite::dim, float>,
translation<I::psite::dim, float> > qk;
//working box
const box<mln_psite(I)> working_box =
Index: mln/registration/icp.hh
--- mln/registration/icp.hh (revision 2542)
+++ mln/registration/icp.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/fun/x2x/all.hh>
+# include <mln/fun/x2v/all.hh>
namespace mln
{
@@ -80,7 +81,7 @@
namespace registration
{
- using namespace fun::x2x::geom;
+ using namespace fun::x2x;
/*! Register point in \p c using a map of closest points \p map
*
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add new properties.
* mln/trait/image/props.hh: Add properties.
* mln/core/image/image2d.hh: Update image2d properties.
core/image/image2d.hh | 4 +
trait/image/props.hh | 115 ++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 116 insertions(+), 3 deletions(-)
Index: mln/trait/image/props.hh
--- mln/trait/image/props.hh (revision 2541)
+++ mln/trait/image/props.hh (working copy)
@@ -76,10 +76,18 @@
// * value
+// pw_io: /any/
+// |
+// +-- read
+// |
+// +-- read_write
+
// value_access: /any/
// |
// + -- direct
// |
+// +-- indirect
+// |
// + -- computed
// value_storage:/any/
@@ -104,14 +112,36 @@
// \ |
// -- + -- cell_and_value_wise
-// * domain values
-
// value_io: /any/
// |
// + -- read_only
// |
// + -- read_write
+// value_alignement:/any/
+// |
+// +-- with_grid
+// |
+// +-- no_aligned
+// |
+// +-- irrelevant
+
+// vw_io: /any/
+// |
+// +-- read
+// |
+// +-- read_write
+
+// vw_set: /any/
+// |
+// +-- /some/
+// | |
+// | +-- uni
+// | |
+// | +-- multi
+// |
+// +-- none
+
// * site localization
// localization: /any/
@@ -264,7 +294,7 @@
{
struct any { protected: any() {} };
struct slow : any { std::string name() const { return "speed::slow"; } };
- struct fast : any { std::string name() const { return "speed::fast"; } };
+ struct fast : any { std::string name() const { return "speedw::fast"; } };
struct fastest
: fast { std::string name() const { return "speed::fastest"; } };
};
@@ -288,16 +318,21 @@
// |
// + -- direct
// |
+// +-- indirect
+// |
// + -- computed
struct value_access
{
struct any { protected: any() {} };
struct direct : any { std::string name() const { return "value_access::direct"; } };
+ struct indirect : any { std::string name() const { return "value_access::indirect"; } };
struct computed : any { std::string name() const { return "value_access::computed"; } };
};
+
+
// value_storage:/any/
// |
// + -- /organized/
@@ -324,7 +359,80 @@
struct disrupted : any { std::string name() const { return "value_storage::disrupted"; } };
};
+// value_alignement:/any/
+// |
+// +-- with_grid
+// |
+// +-- no_aligned
+// |
+// +-- irrelevant
+ struct value_alignement
+ {
+ struct any { protected: any() {} };
+ struct with_grid
+ : any { std::string name() const { return "value_alignement::with_grid"; } };
+ struct not_aligned
+ : any { std::string name() const { return "value_alignement::not_aligned"; } };
+ struct irrelevant
+ : any { std::string name() const { return "value_alignement::irrelevant"; } };
+ };
+
+// pw_io: /any/
+// |
+// +-- read
+// |
+// +-- read_write
+
+ struct pw_io
+ {
+ struct any { protected: any() {} };
+ struct read
+ : any { std::string name() const { return "pw_io::read"; } };
+ struct read_write
+ : any { std::string name() const { return "pw_io::read_write"; } };
+ };
+
+// vw_io: /any/
+// |
+// +-- read
+// |
+// +-- read_write
+
+ struct vw_io
+ {
+ struct any { protected: any() {} };
+ struct some : any { protected: some() {} };
+ struct read
+ : some { std::string name() const { return "pw_io::read"; } };
+ struct read_write
+ : some { std::string name() const { return "pw_io::read_write"; } };
+ struct none
+ : any { std::string name() const { return "pw_io::none"; } };
+ };
+
+// vw_set: /any/
+// |
+// +-- /some/
+// | |
+// | +-- uni
+// | |
+// | +-- multi
+// |
+// +-- none
+
+ struct vw_set
+ {
+ struct any { protected: any() {} };
+ struct some : any { protected: some() {} };
+ struct none : any { protected: none() {} };
+ struct uni
+ : some { std::string name() const { return "vw_set::uni";} };
+ struct multi
+ : some { std::string name() const { return "vw_set::multi";} };
+ };
+
+// DEPRECATED PROPERTY
// value_browsing:/any/
// |
// + -- site_wise_only
@@ -351,6 +459,7 @@
};
+// DEPRECATED PROPERTY
// value_io: /any/
// |
// + -- read_only
Index: mln/core/image/image2d.hh
--- mln/core/image/image2d.hh (revision 2541)
+++ mln/core/image/image2d.hh (working copy)
@@ -98,12 +98,16 @@
typedef trait::image::size::regular size;
// value
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
typedef trait::image::value_access::direct value_access;
typedef trait::image::value_storage::one_block value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_alignement::with_grid value_alignement;
typedef trait::image::value_io::read_write value_io;
// site / domain
+ typedef trait::image::pw_io::read_write pw_io;
typedef trait::image::localization::basic_grid localization;
typedef trait::image::dimension::two_d dimension;
1
0
cleanup-2008 2541: Add accu computation along lines and use it in erosion.
by Thierry Geraud 09 Oct '08
by Thierry Geraud 09 Oct '08
09 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add accu computation along lines and use it in erosion.
* mln/accu/line.hh: New.
* tests/accu/line.cc: New.
* tests/accu/Makefile.am: Update.
* mln/accu/min_h.hh (min_h): New meta-class.
* mln/accu/max_h.hh (max_h): New meta-class.
* mln/morpho/erosion.spe.hh
(erosion_line_on_function): New impl.
(erosion_dispatch_wrt_win): Replace calls to the directional impl
by the line impl for windows being lines.
mln/accu/line.hh | 399 ++++++++++++++++++++++++++++++++++++++++++++++
mln/accu/max_h.hh | 24 ++
mln/accu/min_h.hh | 24 ++
mln/morpho/erosion.spe.hh | 58 ++++++
tests/accu/Makefile.am | 2
tests/accu/line.cc | 58 ++++++
6 files changed, 562 insertions(+), 3 deletions(-)
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 2540)
+++ tests/accu/Makefile.am (working copy)
@@ -8,6 +8,7 @@
compute \
count \
histo \
+ line \
max \
max_h \
mean \
@@ -25,6 +26,7 @@
compute_SOURCES = compute.cc
count_SOURCES = count.cc
histo_SOURCES = histo.cc
+line_SOURCES = line.cc
max_SOURCES = max.cc
max_h_SOURCES = max_h.cc
mean_SOURCES = mean.cc
Index: tests/accu/line.cc
--- tests/accu/line.cc (revision 0)
+++ tests/accu/line.cc (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/accu/line.cc
+ *
+ * \brief Tests on mln::accu::line.
+ */
+
+#include <mln/accu/line.hh>
+#include <mln/accu/min_h.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/debug/iota.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ typedef image2d<unsigned char> I;
+ I ima(1, 5);
+ debug::iota(ima);
+
+ I out(ima.domain());
+ point2d p_start(0, 0);
+ accu::line< accu::meta::min_h, 1 >(ima,
+ p_start, ima.ncols(),
+ 0, // half_length
+ out);
+ mln_assertion(out == ima);
+}
Index: mln/accu/line.hh
--- mln/accu/line.hh (revision 0)
+++ mln/accu/line.hh (revision 0)
@@ -0,0 +1,399 @@
+// 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.
+
+#ifndef MLN_ACCU_LINE_HH
+# define MLN_ACCU_LINE_HH
+
+/// \file mln/accu/line.hh
+/// Run an accumulator on a line of images.
+///
+/// \todo Suppress integer manipulations (redundant with ptr arith).
+
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/core/concept/image.hh>
+
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ // FIXME:
+
+ /*! Line an accumulator onto the pixel values of the image \p input.
+ *
+ * \param[in] input The input image.
+ * \param[in] a The accumulator.
+ * \return The accumulator result.
+ *
+ * This routine runs: \n
+ * tmp = \p a \n
+ * tmp.init() \n
+ * accu::take(\p input, tmp) \n
+ * return tmp.to_result() \n
+ */
+
+ template <typename Meta_Accu, unsigned Dir, // Free parameters.
+ typename I, typename O>
+ void
+ line(const Image<I>& input,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename Meta_Accu, unsigned Dir, // Free parameters.
+ typename I, typename O>
+ void
+ line_tests(const Image<I>& input_,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output_)
+ {
+ mlc_is_a(Meta_Accu, Meta_Accumulator)::check();
+
+ typedef mln_accu_with(Meta_Accu, mln_value(I)) A;
+ mlc_converts_to(mln_result(A), mln_value(O))::check();
+
+ typedef mln_site(I) P;
+ mlc_bool(Dir < P::dim)::check();
+
+ mlc_is(mln_trait_image_value_io(O),
+ mln::trait::image::value_io::read_write)::check();
+
+ const I& input = exact(input_);
+ O& output = exact(output_);
+ mln_precondition(input.has_data());
+ mln_precondition(output.has_data());
+ }
+
+ } // end of namespace mln::accu::internal
+
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename Meta_Accu, unsigned Dir,
+ typename I, typename O>
+ void
+ line(const Image<I>& input_,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output_)
+ {
+ typedef mln_site(I) P;
+ typedef mln_accu_with(Meta_Accu, mln_value(I)) A;
+
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+ // Checks and tests.
+ internal::line_tests<Meta_Accu, Dir>(input,
+ p_start, len,
+ half_length,
+ output);
+
+ // Initialization.
+ const def::coord start = p_start[Dir];
+ const def::coord last = start + len - 1;
+ A a; // Accumulator.
+ a.init();
+ P p; // Current point.
+
+ // Start (first line point).
+ p = p_start;
+ P q = p;
+ for (def::coord c = 0; c <= half_length && c < len; ++c)
+ {
+ a.take(input(q));
+ ++q[Dir];
+ }
+ output(p) = a;
+
+ def::coord& cur = p[Dir];
+ if (cur == last)
+ return;
+
+ // Begin of line.
+
+ P p_plus = p_start;
+ def::coord& plus = p_plus[Dir];
+ plus += half_length;
+
+ while (cur < start + half_length && cur < last)
+ {
+ ++cur;
+ ++plus;
+ if (plus <= last)
+ a.take(input(p_plus));
+ output(p) = a;
+ }
+
+ if (cur == last)
+ return;
+
+ // Middle of line.
+
+ P p_minus = p_start;
+ def::coord& minus = p_minus[Dir];
+ --minus;
+
+ while (cur < last - half_length)
+ {
+ ++cur;
+ ++plus;
+ ++minus;
+ mln_invariant(plus >= start && plus <= last);
+ a.take(input(p_plus));
+ mln_invariant(minus >= start && minus <= last);
+ a.untake(input(p_minus));
+ output(p) = a;
+ }
+
+ if (cur == last)
+ return;
+
+ // End of line.
+
+ while (cur < last)
+ {
+ ++cur;
+ ++minus;
+ mln_invariant(minus >= start && minus <= last);
+ a.untake(input(p_minus));
+ output(p) = a;
+ }
+ }
+
+ } // end of namespace mln::accu::impl::generic
+
+
+
+ template <typename Meta_Accu, unsigned Dir,
+ typename I, typename O>
+ void
+ line_fastest(const Image<I>& input_,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output_)
+ {
+ typedef mln_site(I) P;
+ typedef mln_value(I) V;
+ typedef mln_accu_with(Meta_Accu, V) A;
+
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+ // Checks and tests.
+ internal::line_tests<Meta_Accu, Dir>(input,
+ p_start, len,
+ half_length,
+ output);
+
+ // Initialization.
+
+ const def::coord start = p_start[Dir];
+ const def::coord last = start + len - 1;
+
+ const V* p_in = & input(p_start);
+ V* p_out = & output(p_start);
+
+ mln_delta(P) dp = literal::zero;
+ dp[Dir] = 1;
+ unsigned offset = input.delta_index(dp);
+
+ A a; // Accumulator.
+ a.init();
+
+ // Start (first line point).
+
+ const V* q = p_in;
+ for (def::coord c = 0; c <= half_length && c < len; ++c)
+ {
+ a.take(*q);
+ q += offset;
+ }
+ *p_out = a;
+
+ def::coord cur = p_start[Dir];
+ if (cur == last)
+ return;
+
+ // Begin of line.
+
+ def::coord plus = start + half_length;
+ const V* p_plus = p_in + half_length * offset;
+
+ while (cur < start + half_length && cur < last)
+ {
+ ++cur;
+ p_in += offset;
+ ++plus;
+ p_plus += offset;
+ if (plus <= last)
+ a.take(*p_plus);
+ p_out += offset;
+ *p_out = a;
+ }
+
+ if (cur == last)
+ return;
+
+ // Middle of line.
+
+ def::coord minus = start - 1;
+ const V* p_minus = p_in - offset;
+
+ while (cur < last - half_length)
+ {
+ ++cur;
+ p_in += offset;
+ ++plus;
+ p_plus += offset;
+ ++minus;
+ p_minus += offset;
+ mln_invariant(plus >= start && plus <= last);
+ a.take(*p_plus);
+ mln_invariant(minus >= start && minus <= last);
+ a.untake(*p_minus);
+ p_out += offset;
+ *p_out = a;
+ }
+
+ if (cur == last)
+ return;
+
+ // End of line.
+
+ while (cur < last)
+ {
+ ++cur;
+ p_in += offset;
+ ++minus;
+ p_minus += offset;
+ mln_invariant(minus >= start && minus <= last);
+ a.untake(*p_minus);
+ p_out += offset;
+ *p_out = a;
+ }
+
+ }
+
+
+
+
+ } // end of namespace mln::accu::impl
+
+
+ namespace internal
+ {
+
+ template <typename Meta_Accu, unsigned Dir, // Free parameters.
+ typename I, typename O>
+ void
+ line_dispatch(trait::image::speed::any,
+ const Image<I>& input,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output)
+ {
+ impl::generic::line<Meta_Accu, Dir>(input,
+ p_start, len,
+ half_length,
+ output);
+ }
+
+// template <typename Meta_Accu, unsigned Dir, // Free parameters.
+// typename I, typename O>
+// void
+// line_dispatch(trait::image::speed::fastest,
+// const Image<I>& input,
+// const mln_site(I)& p_start, unsigned len,
+// unsigned half_length,
+// Image<O>& output)
+// {
+// impl::line_fastest<Meta_Accu, Dir>(input,
+// p_start, len,
+// half_length,
+// output);
+// }
+
+ template <typename Meta_Accu, unsigned Dir, // Free parameters.
+ typename I, typename O>
+ void
+ line_dispatch(const Image<I>& input,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output)
+ {
+ line_dispatch<Meta_Accu, Dir>(mln_trait_image_speed(I)(),
+ input,
+ p_start, len,
+ half_length,
+ output);
+ }
+
+ } // end of namespace mln::accu::internal
+
+
+ template <typename Meta_Accu, unsigned Dir, // Free parameters.
+ typename I, typename O>
+ void
+ line(const Image<I>& input,
+ const mln_site(I)& p_start, unsigned len,
+ unsigned half_length,
+ Image<O>& output)
+ {
+ internal::line_tests<Meta_Accu, Dir>(input,
+ p_start, len,
+ half_length,
+ output);
+ internal::line_dispatch<Meta_Accu, Dir>(input,
+ p_start, len,
+ half_length,
+ output);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_LINE_HH
Index: mln/accu/min_h.hh
--- mln/accu/min_h.hh (revision 2540)
+++ mln/accu/min_h.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/accu/histo.hh>
# include <mln/value/set.hh>
+# include <mln/util/pix.hh>
namespace mln
@@ -87,6 +88,29 @@
};
+
+ template <typename I> struct min_h< util::pix<I> >;
+
+
+ namespace meta
+ {
+
+ /*!
+ * \brief Meta accumulator for min.
+ */
+ struct min_h : public Meta_Accumulator< min_h >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::min_h<T> ret;
+ };
+ };
+
+ } // end of namespace mln::meta
+
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename V>
Index: mln/accu/max_h.hh
--- mln/accu/max_h.hh (revision 2540)
+++ mln/accu/max_h.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/accu/histo.hh>
+# include <mln/util/pix.hh>
namespace mln
@@ -86,6 +87,29 @@
};
+
+ template <typename I> struct max_h< util::pix<I> >;
+
+
+ namespace meta
+ {
+
+ /*!
+ * \brief Meta accumulator for max.
+ */
+ struct max_h : public Meta_Accumulator< max_h >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::max_h<T> ret;
+ };
+ };
+
+ } // end of namespace mln::meta
+
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename V>
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2540)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -42,6 +42,8 @@
# include <mln/win/diff.hh>
# include <mln/accu/min_h.hh>
+# include <mln/accu/line.hh>
+
# include <mln/canvas/browsing/snake_fwd.hh>
# include <mln/canvas/browsing/snake_generic.hh>
# include <mln/canvas/browsing/directional.hh>
@@ -220,6 +222,55 @@
}
+ template <typename I, typename G, unsigned Dir, typename C>
+ inline
+ mln_concrete(I)
+ erosion_line_on_function(const Image<I>& input_, const win::line<G,Dir,C>& win)
+ {
+ trace::entering("morpho::impl::erosion_line");
+
+ typedef mln_site(I) P;
+ enum { dim = P::dim };
+
+ const I& input = exact(input_);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ mln_psite(I)
+ pmin = input.domain().pmin(),
+ pmax = input.domain().pmax(),
+ p = pmin;
+
+ const unsigned len = input.domain().len(Dir);
+ const unsigned win_half_length = win.length() / 2;
+
+ do
+ {
+ accu::line< accu::meta::min_h, Dir >(input,
+ p, len,
+ win_half_length,
+ output);
+
+ for (int c = dim - 1; c >= 0; --c)
+ {
+ if (c == int(Dir))
+ continue;
+ if (p[c] != pmax[c])
+ {
+ ++p[c];
+ break;
+ }
+ p[c] = pmin[c];
+ }
+ }
+ while (p != pmin);
+
+ trace::exiting("morpho::impl::erosion_line");
+ return output;
+ }
+
+
template <typename I>
inline
mln_concrete(I)
@@ -627,7 +678,6 @@
initialize(output, input);
}
-
void init_run()
{
min.init();
@@ -941,7 +991,8 @@
if (win.size() <= 3)
return erosion_dispatch_for_generic(input, win);
else
- return erosion_dispatch_for_directional(input, win, 1);
+ return impl::erosion_line_on_function(input, win);
+// return erosion_dispatch_for_directional(input, win, 1);
}
template <typename I>
@@ -951,7 +1002,8 @@
if (win.size() <= 3)
return erosion_dispatch_for_generic(input, win);
else
- return erosion_dispatch_for_directional(input, win, 0);
+ return impl::erosion_line_on_function(input, win);
+// return erosion_dispatch_for_directional(input, win, 0);
}
1
0