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
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-06 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add imaset_ and imacpy_ in sandbox.
* fills_test.cc: .
fills_test.cc | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Index: trunk/milena/sandbox/duhamel/fills_test.cc
===================================================================
--- trunk/milena/sandbox/duhamel/fills_test.cc (revision 1078)
+++ trunk/milena/sandbox/duhamel/fills_test.cc (revision 1079)
@@ -175,6 +175,27 @@
sizeof (mln_value(I)) * k);
}
}
+
+ template <typename I>
+ void imaset_(I& ima, const mln_value(I)& value, std::size_t n)
+ {
+ // FIXME Preconditions
+ mln_value(I)* ptr = &ima[0];
+
+ for (std::size_t i = 0; i < n; ++i)
+ *ptr++ = value;
+ }
+
+ template <typename I>
+ void imacpy_(I& dst, I& src, std::size_t n)
+ {
+ // FIXME Preconditions
+ mln_value(I)* u = &dst[0];
+ mln_value(I)* v = &src[0];
+
+ for (std::size_t i = 0; i < n; ++i)
+ *u++ = *v++;
+ }
}
@@ -184,7 +205,19 @@
using namespace mln;
image2d_b<value::int_u8> ima(3, 3);
+ image2d_b<value::int_u8> i1(3, 3);
+ image2d_b<value::int_u8> i2(3, 3);
+
+ // fill_ptr(ima, 5);
fill_opt2(ima, 5);
debug::println(ima);
+ imaset_(i1, 3, 50);
+ debug::println(i1);
+ mln_assertion (i1[42] == 3);
+ imacpy_(i2, i1, 50);
+ debug::println(i2);
+
+ for (int i = 0; i < 50; ++i)
+ mln_assertion (i1[i] == i2[i]);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-06 Matthieu Garrigues <garrigues.matthieu(a)lrde.epita.fr>
add to_vec_p(win, p_center)
* mln/convert/to_vec_p.hh: add the convertion function
* sandbox/garrigues/TODO: .
* tests/to_vec_p.cc: New. 1d and 2d test
mln/convert/to_vec_p.hh | 17 ++++++++++++
sandbox/garrigues/TODO | 2 +
tests/to_vec_p.cc | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
Index: trunk/milena/tests/to_vec_p.cc
===================================================================
--- trunk/milena/tests/to_vec_p.cc (revision 0)
+++ trunk/milena/tests/to_vec_p.cc (revision 1078)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 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/point1d.cc
+ *
+ * \brief Tests on mln::point1d.
+ */
+
+#include <mln/core/point1d.hh>
+#include <mln/core/point2d.hh>
+#include <mln/core/vec_p.hh>
+
+#include <mln/core/win/segment1d.hh>
+#include <mln/core/win/rectangle2d.hh>
+
+#include <mln/convert/to_vec_p.hh>
+
+int main()
+{
+ using namespace mln;
+
+ typedef vec_p<point1d> vec1d;
+ point1d p1 = make::point1d(6);
+ win::segment1d win1d(5);
+ vec1d v1(convert::to_vec_p(win1d, p1));
+
+ for (int i=0; i < v1.npoints(); i++)
+ std::cout << (v1[i]);
+
+ std::cout << "\n";
+
+ typedef vec_p<point2d> vec2d;
+ point2d p2 = make::point2d(10,10);
+ win::rectangle2d win2d(3, 3);
+ vec2d v2(convert::to_vec_p(win2d, p2));
+
+ for (int i=0; i < v2.npoints(); i++)
+ std::cout << (v2[i]);
+
+}
Index: trunk/milena/mln/convert/to_vec_p.hh
===================================================================
--- trunk/milena/mln/convert/to_vec_p.hh (revision 1077)
+++ trunk/milena/mln/convert/to_vec_p.hh (revision 1078)
@@ -47,6 +47,11 @@
vec_p<mln_point(S)> to_vec_p(const Point_Set<S>& pset);
+ /// Convert a window \p win with a point \p p into a vec_p (point set vector).
+ template <typename W>
+ vec_p<mln_point(W)> to_vec_p(const Window<W>& win, const mln_point(W) p);
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename S>
@@ -61,6 +66,18 @@
return v;
}
+ template <typename W>
+ vec_p<mln_point(W)> to_vec_p(const Window<W>& win, const mln_point(W) p_center)
+ {
+ vec_p<mln_point(W)> v;
+ mln_qiter(W) dp(win, p_center);
+
+ v.reserve(exact(win).ndpoints());
+
+ for_all(dp)
+ v.append(dp);
+ return v;
+ }
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::convert
Index: trunk/milena/sandbox/garrigues/TODO
===================================================================
--- trunk/milena/sandbox/garrigues/TODO (revision 1077)
+++ trunk/milena/sandbox/garrigues/TODO (revision 1078)
@@ -13,7 +13,9 @@
C R core/w_window1d_float.hh
C R core/w_window1d_int.hh
+
C R geom/size1d.hh
+
C R make/box1d.hh
C R make/dpoint1d.hh
C R make/point1d.hh
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-06 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Move fast gaussian out of sandbox
* sandbox/nivault/fast_gaussian.hh: Rename as...
* mln/linear/fast_gaussian.hh: ...this.
Fix.
trunk/milena/mln/linear/fast_gaussian.hh | 318 +++++++++++++++++++++++++++++++
1 file changed, 318 insertions(+)
Index: trunk/milena/mln/linear/fast_gaussian.hh
===================================================================
--- trunk/milena/mln/linear/fast_gaussian.hh (revision 0)
+++ trunk/milena/mln/linear/fast_gaussian.hh (revision 1077)
@@ -0,0 +1,318 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, 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_LINEAR_FAST_GAUSSIAN_HH__
+# define MLN_LINEAR_FAST_GAUSSIAN_HH__
+
+/*! \file mln/linear/fast_gaussian.hh
+ *
+ * \brief Fast gaussian.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/level/paste.hh>
+
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ /*! Fast gaussian of an image \p input
+ *
+ * \pre output.domain = input.domain
+ */
+ template <class I, class O>
+ void
+ gaussian(const Image<I>& input, float sigma,
+ Image<O>& output)
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ struct recursivefilter_coef_
+ {
+
+ /*!
+ ** \brief Constructor.
+ */
+ recursivefilter_coef_(float a0, float a1,
+ float b0, float b1,
+ float c0, float c1,
+ float w0, float w1,
+ float s);
+ std::vector<float> n, d, nm, dm;
+ float sumA, sumC;
+ };
+
+ recursivefilter_coef_::recursivefilter_coef_(float a0, float a1,
+ float b0, float b1,
+ float c0, float c1,
+ float w0, float w1,
+ float s)
+ {
+ n.reserve(5);
+ d.reserve(5);
+ nm.reserve(5);
+ dm.reserve(5);
+
+ b0 /= s;
+ b1 /= s;
+ w0 /= s;
+ w1 /= s;
+
+ float sin0 = sin(w0);
+ float sin1 = sin(w1);
+ float cos0 = cos(w0);
+ float cos1 = cos(w1);
+
+ sumA =
+ (2.0 * a1 * exp( b0 ) * cos0 * cos0 - a0 * sin0 * exp( 2.0 * b0 )
+ + a0 * sin0 - 2.0 * a1 * exp( b0 )) /
+ (( 2.0 * cos0 * exp( b0 ) - exp( 2.0 * b0 ) - 1 ) * sin0);
+
+ sumC =
+ (2.0 * c1 * exp( b1 ) * cos1 * cos1 - c0 * sin1 * exp( 2.0 * b1 )
+ + c0 * sin1 - 2.0 * c1 * exp( b1 ))
+ / (( 2.0 * cos1 * exp( b1 ) - exp( 2.0 * b1 ) - 1 ) * sin1);
+
+ a0 /= (sumA + sumC);
+ a1 /= (sumA + sumC);
+ c0 /= (sumA + sumC);
+ c1 /= (sumA + sumC);
+
+ n[3] =
+ exp( -b1 - 2*b0 ) * (c1 * sin1 - cos1 * c0) +
+ exp( -b0 - 2*b1 ) * (a1 * sin0 - cos0 * a0);
+ n[2] =
+ 2 * exp(-b0 - b1) * ((a0 + c0) * cos1 * cos0 -
+ cos1 * a1 * sin0 -
+ cos0 * c1 * sin1) +
+ c0 * exp(-2 * b0) + a0 * exp(-2 * b1);
+ n[1] =
+ exp(-b1) * (c1 * sin1 - (c0 + 2*a0) * cos1) +
+ exp(-b0) * (a1 * sin0 - (2*c0 + a0) * cos0);
+ n[0] =
+ a0 + c0;
+
+ d[4] = exp(-2 * b0 - 2 * b1);
+ d[3] =
+ -2 * cos0 * exp(-b0 - 2*b1) -
+ 2 * cos1 * exp(-b1 - 2*b0);
+ d[2] =
+ 4 * cos1 * cos0 * exp(-b0 - b1) +
+ exp(-2*b1) + exp(-2*b0);
+ d[1] =
+ -2*exp(-b1) * cos1 - 2 * exp(-b0) * cos0;
+
+ for (unsigned i = 1; i <= 3; ++i)
+ {
+ dm[i] = d[i];
+ nm[i] = n[i] - d[i] * n[0];
+ }
+ dm[4] = d[4];
+ nm[4] = -d[4] * n[0];
+ }
+
+
+
+ template <class WorkType, class I>
+ void
+ recursivefilter_(I& ima,
+ const recursivefilter_coef_& c,
+ const mln_point(I)& start,
+ const mln_point(I)& finish,
+ int len,
+ const mln_dpoint(I)& d)
+ {
+ std::vector<WorkType> tmp1(len);
+ std::vector<WorkType> tmp2(len);
+
+ // The fourth degree approximation implies to have a special
+ // look on the four first points we consider that there is
+ // no signal before 0 (to be discussed)
+
+ // --
+ // Causal part
+
+ tmp1[0] =
+ c.n[0] * ima(start);
+
+ tmp1[1] =
+ c.n[0] * ima(start + d)
+ + c.n[1] * ima(start)
+ - c.d[1] * tmp1[0];
+
+ tmp1[2] =
+ c.n[0] * ima(start + d + d)
+ + c.n[1] * ima(start + d)
+ + c.n[2] * ima(start)
+ - c.d[1] * tmp1[1]
+ - c.d[2] * tmp1[0];
+
+ tmp1[3] =
+ c.n[0] * ima(start + d + d + d)
+ + c.n[1] * ima(start + d + d)
+ + c.n[2] * ima(start + d)
+ + c.n[3] * ima(start)
+ - c.d[1] * tmp1[2] - c.d[2]*tmp1[1]
+ - c.d[3] * tmp1[0];
+
+ mln_point(I) current(start + d + d + d + d);
+ for (mln_coord(I) i = 4; i < len; ++i)
+ {
+ tmp1[i] =
+ c.n[0] * ima(current)
+ + c.n[1] * ima(current - d)
+ + c.n[2] * ima(current - d - d)
+ + c.n[3] * ima(current - d - d - d)
+ - c.d[1] * tmp1[i - 1] - c.d[2]*tmp1[i - 2]
+ - c.d[3] * tmp1[i - 3] - c.d[4]*tmp1[i - 4];
+ current = current + d;
+ }
+
+ // Non causal part
+
+ tmp2[len - 1] = 0;
+
+ tmp2[len - 2] =
+ c.nm[1] * ima(finish);
+
+ tmp2[len - 3] =
+ c.nm[1] * ima(finish - d)
+ + c.nm[2] * ima(finish)
+ - c.dm[1] * tmp2[len-2];
+
+ tmp2[len - 4] =
+ c.nm[1] * ima(finish - d - d)
+ + c.nm[2] * ima(finish - d)
+ + c.nm[3] * ima(finish)
+ - c.dm[1] * tmp2[len-3]
+ - c.dm[2] * tmp2[len-2];
+
+ current = finish - d - d - d ;
+
+ for (int i = len - 5; i >= 0; --i)
+ {
+ tmp2[i] =
+ c.nm[1] * ima(current)
+ + c.nm[2] * ima(current + d)
+ + c.nm[3] * ima(current + d + d)
+ + c.nm[4] * ima(current + d + d + d)
+ - c.dm[1] * tmp2[i+1] - c.dm[2]*tmp2[i+2]
+ - c.dm[3] * tmp2[i+3] - c.dm[4]*tmp2[i+4];
+ current = current - d;
+ }
+
+ // Combine results from causal and non-causal parts.
+
+ current = start;
+ for (int i = 0; i < len; ++i)
+ {
+ ima(current) = tmp1[i] + tmp2[i];
+ current = current + d;
+ }
+ }
+
+
+ template <class I, class F>
+ void
+ gaussian_(Image<I>& img_, const F& coef)
+ {
+ I& img = exact(img_);
+
+ // Apply on rows.
+ for (int j = 0; j < geom::ncols(img); ++j)
+ recursivefilter_<float>(img, coef,
+ make::point2d(-img.border(), j),
+ make::point2d(geom::nrows(img) - 1 + img.border(), j),
+ geom::nrows(img) + 2 * img.border(),
+ make::dpoint2d(1, 0));
+
+ // Apply on columns.
+ for (int i = 0; i < geom::nrows(img); ++i)
+ recursivefilter_<float>(img, coef,
+ make::point2d(i, -img.border()),
+ make::point2d(i, geom::ncols(img) - 1 + img.border()),
+ geom::ncols(img) + 2 * img.border(),
+ make::dpoint2d(0, 1));
+
+ }
+
+
+ template <class I, class F, class O>
+ void
+ gaussian_common_(const Image<I>& in,
+ const F& coef,
+ float sigma,
+ Image<O>& out)
+ {
+ mln_ch_value(O, float) work_img(exact(in).domain());
+ level::paste(in, work_img);
+
+ // On tiny sigma, Derich algorithm doesn't work.
+ // It is the same thing that to convolve with a Dirac.
+ if (sigma > 0.006)
+ gaussian_(work_img, coef);
+ /* Convert the result image to the user-requested datatype.
+ FIXME: We are making an unnecessary copy in case the
+ user expects a ntg::float_s image. */
+ level::paste(work_img, out);
+ }
+
+ } // end of namespace mln::linear::impl
+
+ // Facade.
+
+ template <class I, class O>
+ void
+ gaussian(const Image<I>& input, float sigma,
+ Image<O>& output)
+ {
+ recursivefilter_coef_
+ coef(1.68f, 3.735f,
+ 1.783f, 1.723f,
+ -0.6803f, -0.2598f,
+ 0.6318f, 1.997f,
+ sigma);
+
+ gaussian_common_(in, coef, sigma, out);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+
+#endif // MLN_LINEAR_FAST_GAUSSIAN_HH__
Index: trunk/milena/sandbox/nivault/fast_gaussian.hh (deleted)
===================================================================
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move gaussian filter test out of sandbox.
* sandbox/nivault/tests/test.cc: Rename as...
* tests/linear_gaussian.cc: ...this.
Fix.
linear_gaussian.cc | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
Index: tests/linear_gaussian.cc
--- tests/linear_gaussian.cc (revision 1075)
+++ tests/linear_gaussian.cc (working copy)
@@ -25,19 +25,35 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+/*! \file tests/linear_gaussian.cc
+ *
+ * \brief Test on mln::linear::gaussian.
+ */
+
#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u_sat.hh>
+
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
-#include <fast_gaussian.hh>
+#include <mln/level/transform.hh>
+#include <mln/level/saturate.hh>
+#include <mln/math/round.hh>
+
+#include <mln/linear/gaussian.hh>
+
int main()
{
- mln::image2d_b<mln::value::int_u<8u> > im1 = mln::io::load_pgm("../../../img/lena.pgm");
- mln_precondition(im1.has_data());
- mln::image2d_b<mln::value::int_u<8u> > im2(im1.domain());
+ using namespace mln;
+
+ image2d_b< value::int_u8 > lena = io::load_pgm("../img/lena.pgm");
- mln::linear::gaussian(im1, 2, im2);
+ image2d_b<float> tmp(lena.domain());
+ linear::gaussian(lena, 5.1f, tmp);
- mln::io::save_pgm(im2, "gausslena.pgm");
+ image2d_b< value::int_u_sat<8> > out(lena.domain());
+ level::transform(tmp, math::round<int>(), out);
+ io::save_pgm(out, "out.pgm");
}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Tiny fix and add some preconditions.
* mln/convert/to_image.hh: Fix.
* mln/linear/line_convolve.hh: Add todo.
* mln/canvas/labeling.hh: Add comments.
* mln/labeling/flat_zones.hh,
* mln/labeling/foreground.hh,
* mln/labeling/regional_minima.hh,
* mln/labeling/regional_maxima.hh: Add precondition.
* mln/labeling/background.hh: .
* mln/labeling/level.hh (level_): Rename as...
(level_t): ...this.
(level_): New.
canvas/labeling.hh | 6 ++++++
convert/to_image.hh | 3 ++-
labeling/background.hh | 1 +
labeling/flat_zones.hh | 1 +
labeling/foreground.hh | 1 +
labeling/level.hh | 27 ++++++++++++++++++++-------
labeling/regional_maxima.hh | 1 +
labeling/regional_minima.hh | 1 +
linear/line_convolve.hh | 2 ++
9 files changed, 35 insertions(+), 8 deletions(-)
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh (revision 1074)
+++ mln/convert/to_image.hh (working copy)
@@ -33,6 +33,7 @@
* \brief Conversions to mln::Image.
*/
+# include <mln/core/image1d_b.hh>
# include <mln/core/image2d_b.hh>
# include <mln/core/concept/point_set.hh>
@@ -132,7 +133,7 @@
mln_precondition(! win.is_empty());
typedef mln_point(W) P;
- box2d b = geom::bbox(win);
+ box_<P> b = geom::bbox(win);
mln_image_from(W, bool) ima(b);
level::fill(ima, false);
mln_qiter(W) q(win, P::zero);
Index: mln/linear/line_convolve.hh
--- mln/linear/line_convolve.hh (revision 1074)
+++ mln/linear/line_convolve.hh (working copy)
@@ -54,6 +54,8 @@
* its symmetrization is handled by the client.
*
* \pre output.domain = input.domain
+ *
+ * \todo Optimize.
*/
template <typename I, typename W, unsigned N, typename O>
void line_convolve(const Image<I>& input, W (&weights)[N],
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 1074)
+++ mln/canvas/labeling.hh (working copy)
@@ -44,6 +44,8 @@
namespace canvas
{
+ // General version.
+
template <typename F>
struct labeling
{
@@ -149,6 +151,10 @@
};
+
+ // FIXME: Fast version.
+
+
} // end of namespace mln::canvas
} // end of namespace mln
Index: mln/labeling/flat_zones.hh
--- mln/labeling/flat_zones.hh (revision 1074)
+++ mln/labeling/flat_zones.hh (working copy)
@@ -94,6 +94,7 @@
Image<O>& output,
unsigned& nlabels)
{
+ mln_precondition(exact(output).domain() = exact(input).domain());
typedef impl::flat_zones_<I,N,O> F;
F f(exact(input), exact(nbh), exact(output));
canvas::labeling<F> run(f);
Index: mln/labeling/level.hh
--- mln/labeling/level.hh (revision 1074)
+++ mln/labeling/level.hh (working copy)
@@ -66,8 +66,10 @@
namespace impl
{
+ // Functors.
+
template <typename I_, typename N_, typename O_>
- struct level_ : base_<I_,N_,O_>
+ struct level_t : base_<I_,N_,O_>
{
typedef mln_point(I_) P;
@@ -84,13 +86,28 @@
const mln_value(I_)& val;
- level_(const I_& input, const mln_value(I_)& val, const N_& nbh, O_& output)
+ level_t(const I_& input, const mln_value(I_)& val, const N_& nbh, O_& output)
: base_<I_,N_,O_>(input, nbh, output),
s(input.domain()),
val(val)
{}
};
+ // Routines.
+
+ template <typename I, typename N, typename O>
+ bool level_(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
+ Image<O>& output, unsigned& nlabels)
+ {
+ typedef impl::level_t<I,N,O> F;
+ F f(exact(input), val, exact(nbh), exact(output));
+ canvas::labeling<F> run(f);
+ nlabels = f.nlabels;
+ return f.status;
+ }
+
+ // FIXME: Add fast versions.
+
} // end of namespace mln::labeling::impl
@@ -101,11 +118,7 @@
Image<O>& output, unsigned& nlabels)
{
mln_precondition(exact(output).domain() = exact(input).domain());
- typedef impl::level_<I,N,O> F;
- F f(exact(input), val, exact(nbh), exact(output));
- canvas::labeling<F> run(f);
- nlabels = f.nlabels;
- return f.status;
+ return impl::level_(exact(input), val, nbh, output, nlabels);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/labeling/foreground.hh
--- mln/labeling/foreground.hh (revision 1074)
+++ mln/labeling/foreground.hh (working copy)
@@ -66,6 +66,7 @@
Image<O>& output,
unsigned& nlabels)
{
+ mln_precondition(exact(output).domain() = exact(input).domain());
return labeling::level(input, true, nbh, output, nlabels);
}
Index: mln/labeling/regional_minima.hh
--- mln/labeling/regional_minima.hh (revision 1074)
+++ mln/labeling/regional_minima.hh (working copy)
@@ -103,6 +103,7 @@
bool regional_minima(const Image<I>& input, const Neighborhood<N>& nbh,
Image<O>& output, unsigned& nlabels)
{
+ mln_precondition(exact(output).domain() = exact(input).domain());
typedef impl::regional_minima_<I,N,O> F;
F f(exact(input), exact(nbh), exact(output));
canvas::labeling<F> run(f);
Index: mln/labeling/regional_maxima.hh
--- mln/labeling/regional_maxima.hh (revision 1074)
+++ mln/labeling/regional_maxima.hh (working copy)
@@ -103,6 +103,7 @@
bool regional_maxima(const Image<I>& input, const Neighborhood<N>& nbh,
Image<O>& output, unsigned& nlabels)
{
+ mln_precondition(exact(output).domain() = exact(input).domain());
typedef impl::regional_maxima_<I,N,O> F;
F f(exact(input), exact(nbh), exact(output));
canvas::labeling<F> run(f);
Index: mln/labeling/background.hh
--- mln/labeling/background.hh (revision 1074)
+++ mln/labeling/background.hh (working copy)
@@ -66,6 +66,7 @@
Image<O>& output,
unsigned& nlabels)
{
+ mln_precondition(exact(output).domain() = exact(input).domain());
return labeling::level(input, false, nbh, output, nlabels);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-06 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Median specialized for fast image
* sandbox/nivault/median.hh: New.
median.hh | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 215 insertions(+)
Index: trunk/milena/sandbox/nivault/median.hh
===================================================================
--- trunk/milena/sandbox/nivault/median.hh (revision 0)
+++ trunk/milena/sandbox/nivault/median.hh (revision 1074)
@@ -0,0 +1,215 @@
+// Copyright (C) 2007 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_LEVEL_MEDIAN_HH
+# define MLN_LEVEL_MEDIAN_HH
+
+/*! \file mln/level/median.hh
+ *
+ * \brief Median filtering of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/geom/size2d.hh>
+
+# include <mln/core/window2d.hh>
+# include <mln/core/win/hline2d.hh>
+# include <mln/core/t_image.hh>
+
+# include <mln/accu/median.hh>
+# include <mln/canvas/sbrowsing.hh>
+
+# include <mln/geom/shift.hh>
+# include <mln/set/diff.hh>
+
+
+namespace mln
+{
+
+ namespace level
+ {
+
+ /*! Compute in \p output the median filter of image \p input by
+ * the window \p win.
+ *
+ * \param[in] input The image to be filtered.
+ * \param[in] win The window.
+ * \param[in,out] output The output image.
+ *
+ * \pre \p input and \p output have to be initialized.
+ */
+ template <typename I, typename W, typename O>
+ void median(const Image<I>& input, const Window<W>& win,
+ Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+
+ template <typename I, typename O>
+ void median(const Image<I>& input_, const win::hline2d& win, O& output)
+ {
+
+ I& input = exact(input_);
+ typedef mln_coord(I) coord;
+ const coord
+ min_row = geom::min_row(input),
+ max_row = geom::max_row(input),
+ min_col = geom::min_col(input),
+ max_col = geom::max_col(input);
+ const coord half = win.length() / 2;
+
+ point2d p;
+ coord& row = p.row();
+ coord& col = p.col();
+
+ point2d pt;
+ coord& ct = pt.col();
+
+ point2d pu;
+ coord& cu = pu.col();
+
+ accu::median<mln_vset(I)> med(input.values());
+
+ for (row = min_row; row <= max_row; ++row)
+ {
+ pt.row() = pu.row() = row;
+
+ // initialization (before first point of the row)
+ med.init();
+ for (ct = min_col; ct < min_col + half; ++ct)
+ med.take(input(pt));
+
+ // left columns (just take new points)
+ for (col = min_col; col <= min_col + half; ++col, ++ct)
+ {
+ med.take(input(pt));
+ output(p) = med.to_value();
+ }
+
+ // middle columns (both take and untake)
+ cu = min_col;
+ for (; col <= max_col - half; ++cu, ++col, ++ct)
+ {
+ med.take(input(pt));
+ med.untake(input(pu));
+ output(p) = med.to_value();
+ }
+
+ // right columns (now just untake old points)
+ for (; col <= max_col; ++cu, ++col)
+ {
+ med.untake(input(pu));
+ output(p) = med.to_value();
+ }
+ }
+ }
+
+ template <typename I, typename O>
+ void median(const Fast_Image<I>& input_, const win::hline2d& win, O& output)
+ {
+
+ I& input = exact(input_);
+ border::resize(input, win.delta());;
+ border::duplicate(input);
+
+ typedef mln_coord(I) coord;
+ const coord
+ min_row = geom::min_row(input),
+ max_row = geom::max_row(input),
+ min_col = geom::min_col(input),
+ max_col = geom::max_col(input);
+ const coord half = win.length() / 2;
+
+ point2d p;
+ coord& row = p.row();
+ coord& col = p.col();
+
+ point2d pt;
+ coord& ct = pt.col();
+
+ point2d pu;
+ coord& cu = pu.col();
+
+ accu::median<mln_vset(I)> med(input.values());
+
+ for (row = min_row; row <= max_row; ++row)
+ {
+ pt.row() = pu.row() = row;
+
+ // initialization (before first point of the row)
+ med.init();
+ for (ct = min_col - half; ct < min_col + half; ++ct)
+ med.take(input(pt));
+
+ // middle columns (both take and untake)
+ cu = min_col;
+ for (col = min_col; col <= max_col; ++cu, ++col, ++ct)
+ {
+ med.take(input(pt));
+ med.untake(input(pu));
+ output(p) = med.to_value();
+ }
+
+ }
+ }
+
+ template <typename I, typename O>
+ void median(const I& input, const win::vline2d& win, O& output)
+ {
+ t_image<O> swap_output = swap_coords(output, 0, 1);
+ impl::median(swap_coords(input, 0, 1),
+ win::hline2d(win.length()),
+ swap_output);
+ }
+
+
+ } // end of namespace mln::level::impl
+
+
+ // facade
+
+ template <typename I, typename W, typename O>
+ void median(const Image<I>& input, const Window<W>& win,
+ Image<O>& output)
+ {
+ mln_assertion(exact(output).domain() == exact(input).domain());
+ impl::median(exact(input), exact(win), exact(output));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_MEDIAN_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-06 Matthieu Garrigues <garrigues.matthieu(a)lrde.epita.fr>
bug fix in line2d.hh
* core/line2d.hh: col = beg_.row() replaced by col = beg_.col();
line2d.hh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: trunk/milena/mln/core/line2d.hh
===================================================================
--- trunk/milena/mln/core/line2d.hh (revision 1072)
+++ trunk/milena/mln/core/line2d.hh (revision 1073)
@@ -115,7 +115,7 @@
srow = math::sign(dp.row()), drow = math::abs(dp.row()), ddrow = 2 * drow,
scol = math::sign(dp.col()), dcol = math::abs(dp.col()), ddcol = 2 * dcol,
row = beg_.row(),
- col = beg_.row();
+ col = beg_.col();
if ( dcol > drow )
{
int e = ddrow - dcol;
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-05 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add fill optimized.
* sandbox/duhamel/compil.cmd: Compile fills_test.cc.
* sandbox/duhamel/fills_test.cc: Here.
compil.cmd | 1
fills_test.cc | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 191 insertions(+)
Index: trunk/milena/sandbox/duhamel/compil.cmd
===================================================================
--- trunk/milena/sandbox/duhamel/compil.cmd (revision 0)
+++ trunk/milena/sandbox/duhamel/compil.cmd (revision 1072)
@@ -0,0 +1 @@
+g++-4.1 -ansi -pedantic -W -Wall -Wextra -Wconversion -I../.. fills_test.cc
Property changes on: trunk/milena/sandbox/duhamel/compil.cmd
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/duhamel/fills_test.cc
===================================================================
--- trunk/milena/sandbox/duhamel/fills_test.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/fills_test.cc (revision 1072)
@@ -0,0 +1,190 @@
+// Copyright (C) 2007 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/image2d_b.cc
+ *
+ * \brief Tests on mln::image2d_b.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/println.hh>
+
+
+#include <mln/geom/nrows.hh>
+#include <mln/geom/ncols.hh>
+
+#include <mln/level/fill.hh>
+
+namespace mln
+{
+
+ // 1.08
+ template <typename I>
+ void fill_naive(I& ima, const mln_value(I)& value)
+ {
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = value;
+ }
+
+ // 0.08
+ template <typename I>
+ void fill_memset(I& ima, const mln_value(I)& value)
+ {
+ mln_precondition(sizeof(mln_value(I)) == 1);
+ std::memset((void*)(ima.buffer()),
+ *(const int*)(& value), // violent cast
+ sizeof(mln_value(I)) * ima.ncells());
+ }
+
+ // 0.26
+ template <typename I>
+ void fill_pixel(I& ima, const mln_value(I)& value)
+ {
+ int n = 0;
+ mln_pixter(I) pix(ima);
+ for_all(pix)
+ {
+ ++n;
+ pix.val() = value;
+ }
+ std::cout << "n = "
+ << n
+ << std::endl;
+ }
+
+ // 0.10
+ template <typename I>
+ void fill_ptr(I& ima, const mln_value(I)& value)
+ {
+ mln_value(I)* ptr = & ima[0];
+ std::size_t n = ima.ncells();
+
+ for (std::size_t i = 0; i < n; ++i)
+ *ptr++ = value;
+
+ std::cout << "n = "
+ << n
+ << std::endl;
+ }
+
+ template <typename I>
+ void fill_opt1(I& ima, const mln_value(I)& value)
+ {
+ mln_pixter(I) pix(ima);
+ mln_pixter(I) s(ima);
+
+ pix.start();
+ s.start ();
+
+ mln_coord(I) min_row = geom::min_row(exact(ima));
+ mln_coord(I) min_col = geom::min_col(exact(ima));
+ mln_coord(I) max_row = geom::max_row(exact(ima));
+ mln_coord(I) max_col = geom::max_col(exact(ima));
+
+ mln_coord(I) nb_cols = max_col - min_col;
+ mln_coord(I) nb_rows = max_row - min_row;
+
+ std::cerr << "min_row : "
+ << min_row
+ << std::endl
+ << "max_row : "
+ << max_row
+ << std::endl
+ << "min_col : "
+ << min_col
+ << std::endl
+ << "max_col : "
+ << max_col
+ << std::endl;
+
+ // fill row
+ for (std::size_t i = 0; i < nb_cols; ++i)
+ {
+ pix.val () = value;
+ pix.next ();
+ }
+
+ for (std::size_t i = 1; i < nb_rows; ++i)
+ {
+ // copy row into current row
+ std::memcpy (&(pix.val ()),
+ &(s.val ()),
+ sizeof(mln_value(I)) * nb_cols);
+
+ // Jump to next row
+ for (std::size_t j = 0; j < nb_cols; ++j)
+ pix.next ();
+ }
+
+ std::memcpy (&(pix.val ()),
+ &(s.val ()),
+ sizeof(mln_value(I)) * nb_cols);
+ }
+
+ template <typename I>
+ void fill_opt2(I& ima, const mln_value(I)& value)
+ {
+ mln_value(I)* ptr = & ima[0];
+
+ mln_pixter(I) pix(ima);
+ mln_pixter(I) s(ima);
+ point2d min = ima.bbox ().pmin ();
+ point2d u = min;
+ point2d v = min + down;
+ std::size_t k = ima.offset (down);
+ std::size_t max = ima.ncells() / k;
+
+ for (std::size_t i = 0; i < k; ++i)
+ *ptr++ = value;
+
+ ptr = & ima[0];
+
+ for (std::size_t i = 0;
+ i < max - 1;
+ ++i)
+ {
+ u = u + down;
+ std::memcpy (&ima[ima.offset (u - min)],
+ ptr,
+ sizeof (mln_value(I)) * k);
+ }
+ }
+}
+
+
+
+int main()
+{
+ using namespace mln;
+ image2d_b<value::int_u8> ima(3, 3);
+
+ fill_opt2(ima, 5);
+ debug::println(ima);
+
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-05 Matthieu Garrigues <garrigues.matthieu(a)lrde.epita.fr>
Add 1d handling
* mln/convert/to_image.hh: .
* mln/core/box1d.hh: New.
* mln/core/dpoint1d.hh: New.
* mln/core/image1d_b.hh: New.
* mln/core/internal/box_impl.hh: .
* mln/core/neighb1d.hh: New.
* mln/core/pixter1d_b.hh: New.
* mln/core/point1d.hh: New.
* mln/core/w_window1d_float.hh: New.
* mln/core/w_window1d_int.hh: New.
* mln/core/win/segment1d.hh: New.
* mln/core/window1d.hh: New.
* mln/geom/max_ind.hh: New.
* mln/geom/min_ind.hh: New.
* mln/geom/ninds.hh: New.
* mln/geom/size1d.hh: New.
* mln/make/box1d.hh: New.
* mln/make/dpoint1d.hh: New.
* mln/make/point1d.hh: New.
* mln/make/w_window1d.hh: New.
* mln/make/w_window1d_int.hh: New.
* mln/make/window1d.hh: New.
* sandbox/garrigues/TODO: New.
* tests/box1d.cc: New.
* tests/dpoint1d.cc: New.
* tests/image1d_b.cc: New.
* tests/pixter1d_b.cc: New.
* tests/point1d.cc: New.
* tests/w_window1d_int.cc: New.
* tests/window1d.cc: New.
mln/convert/to_image.hh | 6
mln/core/box1d.hh | 58 ++++
mln/core/dpoint1d.hh | 66 +++++
mln/core/image1d_b.hh | 516 ++++++++++++++++++++++++++++++++++++++++++
mln/core/internal/box_impl.hh | 33 ++
mln/core/neighb1d.hh | 79 ++++++
mln/core/pixter1d_b.hh | 90 +++++++
mln/core/point1d.hh | 56 ++++
mln/core/w_window1d_float.hh | 56 ++++
mln/core/w_window1d_int.hh | 56 ++++
mln/core/win/segment1d.hh | 181 ++++++++++++++
mln/core/window1d.hh | 56 ++++
mln/geom/max_ind.hh | 66 +++++
mln/geom/min_ind.hh | 66 +++++
mln/geom/ninds.hh | 67 +++++
mln/geom/size1d.hh | 39 +++
mln/make/box1d.hh | 96 +++++++
mln/make/dpoint1d.hh | 70 +++++
mln/make/point1d.hh | 71 +++++
mln/make/w_window1d.hh | 86 +++++++
mln/make/w_window1d_int.hh | 75 ++++++
mln/make/window1d.hh | 81 ++++++
sandbox/garrigues/TODO | 22 +
tests/box1d.cc | 43 +++
tests/dpoint1d.cc | 53 ++++
tests/image1d_b.cc | 48 +++
tests/pixter1d_b.cc | 94 +++++++
tests/point1d.cc | 56 ++++
tests/w_window1d_int.cc | 73 +++++
tests/window1d.cc | 56 ++++
30 files changed, 2415 insertions(+)
Index: trunk/milena/tests/window1d.cc
===================================================================
--- trunk/milena/tests/window1d.cc (revision 0)
+++ trunk/milena/tests/window1d.cc (revision 1071)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 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/window1d.cc
+ *
+ * \brief Tests on mln::window1d.
+ */
+
+#include <mln/core/window1d.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ window1d w;
+
+ mln_assertion(w.is_centered() == false);
+ mln_assertion(w.is_symmetric() == true);
+
+ w.insert(make::dpoint1d(-1));
+ w.insert(make::dpoint1d( 1));
+
+ image1d_b<bool> ima = convert::to_image(w);
+ debug::println(ima);
+
+ mln_assertion(w.delta() == 1);
+}
Index: trunk/milena/tests/w_window1d_int.cc
===================================================================
--- trunk/milena/tests/w_window1d_int.cc (revision 0)
+++ trunk/milena/tests/w_window1d_int.cc (revision 1071)
@@ -0,0 +1,73 @@
+// Copyright (C) 2007 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/w_window1d_int.cc
+ *
+ * \brief Tests on mln::w_window1d_int.
+ */
+
+#include <mln/core/w_window1d_int.hh>
+
+#include <mln/convert/to_image.hh>
+#include <mln/convert/to_w_window.hh>
+
+#include <mln/convert/to_fun.hh>
+#include <mln/estim/sum.hh>
+
+
+int f(mln::point1d p)
+{
+ return p.ind ();
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ int ws[] = { -1, 0, 1,
+ -2, 0, 2,
+ -1, 0, 1 };
+ w_window1d_int w_win = make::w_window1d(ws);
+
+ image1d_b<int> ima = convert::to_image(w_win);
+ w_window1d_int w_win_2 = convert::to_w_window(ima);
+ mln_assertion(w_win_2 == w_win);
+ }
+
+ {
+ w_window1d_int w_win = make::w_window(win::rectangle1d(3, 5),
+ convert::to_fun(f));
+ // -3 -2 -1 0 +1
+ // -2 -1 0 +1 +2
+ // -1 0 +1 +2 +3
+ image1d_b<int> ima = convert::to_image(w_win);
+ mln_assertion(estim::sum(ima) == 0);
+ }
+
+}
Index: trunk/milena/tests/box1d.cc
===================================================================
--- trunk/milena/tests/box1d.cc (revision 0)
+++ trunk/milena/tests/box1d.cc (revision 1071)
@@ -0,0 +1,43 @@
+// Copyright (C) 2007 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/box1d.cc
+ *
+ * \brief Tests on mln::box1d.
+ */
+
+#include <mln/core/box1d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ box1d b = make::box1d(2);
+ mln_assertion(b.ninds() == 2);
+}
Index: trunk/milena/tests/image1d_b.cc
===================================================================
--- trunk/milena/tests/image1d_b.cc (revision 0)
+++ trunk/milena/tests/image1d_b.cc (revision 1071)
@@ -0,0 +1,48 @@
+// Copyright (C) 2007 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/image1d_b.cc
+ *
+ * \brief Tests on mln::image1d_b.
+ */
+
+#include <mln/core/image1d_b.hh>
+#include <mln/geom/size1d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ const unsigned ninds = 1;
+ const unsigned border = 4;
+
+ image1d_b<int> f(ninds, border);
+
+ mln_assertion(f.npoints() == ninds);
+ mln_assertion(f.ncells() == (ninds + 2 * border));
+}
Index: trunk/milena/tests/dpoint1d.cc
===================================================================
--- trunk/milena/tests/dpoint1d.cc (revision 0)
+++ trunk/milena/tests/dpoint1d.cc (revision 1071)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 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/dpoint1d.cc
+ *
+ * \brief Tests on mln::dpoint1d.
+ */
+
+#include <mln/core/dpoint1d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ point1d p, q;
+ dpoint1d dp;
+
+ p = make::point1d(1);
+ q = make::point1d(4);
+ dp = make::dpoint1d(3);
+
+ mln_assertion(dp == q - p);
+ mln_assertion(q == p + dp);
+
+ const int (&vec)[1] = dp.to_vec();
+ mln_assertion(vec[0] == 3);
+}
Index: trunk/milena/tests/pixter1d_b.cc
===================================================================
--- trunk/milena/tests/pixter1d_b.cc (revision 0)
+++ trunk/milena/tests/pixter1d_b.cc (revision 1071)
@@ -0,0 +1,94 @@
+// Copyright (C) 2007 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/pixter1d_b.cc
+ *
+ * \brief Tests on mln::fwd_pixter1d_b.
+ */
+
+#include <mln/core/image1d_b.hh>
+
+
+const unsigned size = 20;
+const int v = 51;
+
+
+template <typename I>
+void test_fill(I& ima)
+{
+ mln_pixter(I) pxl(ima);
+ unsigned i = 0;
+ for_all(pxl)
+ {
+ ++i;
+ pxl.val() = v;
+ }
+ mln_assertion(i == size);
+ mln_assertion(! pxl.is_valid());
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ mln_assertion(ima(p) == v);
+}
+
+
+template <typename I>
+void test_const(const I& imac, I& ima)
+{
+ {
+ mln_pixter(const I) pxl(imac); // const is mandatory
+ pxl.start();
+ mln_assertion(pxl.val() == v);
+ // pxl.val() = v; // error is OK since pixter on 'const I'
+ }
+ {
+ // mln_pixter(I) pxl_(imac); // error is OK since mutable I but const imac
+ mln_pixter(I) pxl(ima);
+ pxl.start();
+ pxl.val() = 2 * pxl.val();
+ mln_assertion(pxl.val() == 2 * v);
+ }
+ {
+ mln_pixter(const I) pxl(ima); // const promotion is OK
+ pxl.start();
+ mln_assertion(pxl.val() == 2 * v);
+ // pxl.val() = v; // error is OK since pixter on 'const I'
+ }
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image1d_b<int> I;
+ I ima(size);
+
+ test_fill(ima);
+ test_const(ima, ima);
+}
Index: trunk/milena/tests/point1d.cc
===================================================================
--- trunk/milena/tests/point1d.cc (revision 0)
+++ trunk/milena/tests/point1d.cc (revision 1071)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 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/point1d.cc
+ *
+ * \brief Tests on mln::point1d.
+ */
+
+#include <mln/core/point1d.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ point1d p, q;
+
+ // assignment
+
+ p[0] = 4;
+ p.ind() += 1;
+ mln_assertion(p.ind() == 5 && p[0] == 5);
+
+ // construction
+ q = make::point1d(5);
+ mln_assertion(p == q);
+
+ q.set_all(0);
+ for (unsigned i = 0; i < p.dim; ++i)
+ mln_assertion(q[i] == 0);
+}
Index: trunk/milena/mln/convert/to_image.hh
===================================================================
--- trunk/milena/mln/convert/to_image.hh (revision 1070)
+++ trunk/milena/mln/convert/to_image.hh (revision 1071)
@@ -71,6 +71,12 @@
typedef image2d_b<V> ret;
};
+ template <typename V>
+ struct helper_image_from_< 1, V >
+ {
+ typedef image1d_b<V> ret;
+ };
+
} // end of namespace mln::internal
Index: trunk/milena/mln/geom/ninds.hh
===================================================================
--- trunk/milena/mln/geom/ninds.hh (revision 0)
+++ trunk/milena/mln/geom/ninds.hh (revision 1071)
@@ -0,0 +1,67 @@
+// Copyright (C) 2007 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_GEOM_NINDS_HH
+# define MLN_GEOM_NINDS_HH
+
+/*! \file mln/geom/ninds.hh
+ *
+ * \brief Give the number of inds of an image.
+ */
+
+# include <mln/geom/min_ind.hh>
+# include <mln/geom/max_ind.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the number of inds of an image.
+ template <typename I>
+ unsigned ninds(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ unsigned ninds(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return geom::max_ind(ima) - geom::min_ind(ima) + 1;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_NINDS_HH
Index: trunk/milena/mln/geom/min_ind.hh
===================================================================
--- trunk/milena/mln/geom/min_ind.hh (revision 0)
+++ trunk/milena/mln/geom/min_ind.hh (revision 1071)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 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_GEOM_MIN_IND_HH
+# define MLN_GEOM_MIN_IND_HH
+
+/*! \file mln/geom/min_ind.hh
+ *
+ * \brief Give the minimum ind of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the minimum ind of an image.
+ template <typename I>
+ mln_coord(I) min_ind(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) min_ind(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmin().ind();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MIN_IND_HH
Index: trunk/milena/mln/geom/size1d.hh
===================================================================
--- trunk/milena/mln/geom/size1d.hh (revision 0)
+++ trunk/milena/mln/geom/size1d.hh (revision 1071)
@@ -0,0 +1,39 @@
+// Copyright (C) 2007 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_GEOM_SIZE1D_HH
+# define MLN_GEOM_SIZE1D_HH
+
+/*! \file mln/geom/size1d.hh
+ *
+ * \brief Facade to include 1D size access routines.
+ */
+
+# include <mln/geom/ninds.hh>
+
+
+#endif // ! MLN_GEOM_SIZE1D_HH
Index: trunk/milena/mln/geom/max_ind.hh
===================================================================
--- trunk/milena/mln/geom/max_ind.hh (revision 0)
+++ trunk/milena/mln/geom/max_ind.hh (revision 1071)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 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_GEOM_MAX_IND_HH
+# define MLN_GEOM_MAX_IND_HH
+
+/*! \file mln/geom/max_ind.hh
+ *
+ * \brief Give the maximum ind of an image.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Give the maximum ind of an image.
+ template <typename I>
+ mln_coord(I) max_ind(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ mln_coord(I) max_ind(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).has_data());
+ return exact(ima).bbox().pmax().ind();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_MAX_IND_HH
Index: trunk/milena/mln/core/neighb1d.hh
===================================================================
--- trunk/milena/mln/core/neighb1d.hh (revision 0)
+++ trunk/milena/mln/core/neighb1d.hh (revision 1071)
@@ -0,0 +1,79 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_NEIGHB1D_HH
+# define MLN_CORE_NEIGHB1D_HH
+
+/*! \file mln/core/neighb1d.hh
+ *
+ * \brief Definition of the mln::neighb1d alias and of some classical
+ * 1D neighborhoods.
+ */
+
+# include <cmath>
+# include <mln/core/neighb.hh>
+# include <mln/core/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a neighborhood defined on the 1D square
+ * grid with integer coordinates.
+ */
+ typedef neighb_<dpoint1d> neighb1d;
+
+
+ /*! \brief 2-connectivity neighborhood on the 1D grid.
+ *
+ * o x o
+ *
+ * \return A neighb1d.
+ */
+ const neighb1d& c2();
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const neighb1d& c2()
+ {
+ static bool flower = true;
+ static neighb1d it;
+ if (flower)
+ {
+ it.insert(make::dpoint1d(+1));
+ flower = false;
+ }
+ return it;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_NEIGHB1D_HH
Index: trunk/milena/mln/core/dpoint1d.hh
===================================================================
--- trunk/milena/mln/core/dpoint1d.hh (revision 0)
+++ trunk/milena/mln/core/dpoint1d.hh (revision 1071)
@@ -0,0 +1,66 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_DPOINT1D_HH
+# define MLN_CORE_DPOINT1D_HH
+
+/*! \file mln/core/dpoint1d.hh
+ *
+ * \brief Definition of the mln::dpoint1d alias and of its
+ * construction routine.
+ */
+
+# include <mln/core/dpoint.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a delta-point defined on the 1D square
+ * grid with integer coordinates.
+ */
+ typedef dpoint_<1,int> dpoint1d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/dpoint1d.hh>
+# include <mln/core/point1d.hh>
+
+
+namespace mln
+{
+
+ // FIXME: Doc!
+ const dpoint1d prev = make::dpoint1d( -1 );
+ const dpoint1d next = make::dpoint1d( +1 );
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_DPOINT1D_HH
Index: trunk/milena/mln/core/pixter1d_b.hh
===================================================================
--- trunk/milena/mln/core/pixter1d_b.hh (revision 0)
+++ trunk/milena/mln/core/pixter1d_b.hh (revision 1071)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_PIXTER1D_B_HH
+# define MLN_CORE_PIXTER1D_B_HH
+
+/*! \file mln/core/pixter1d_b.hh
+ *
+ * \brief Pixel iterator class on a image 1d with border.
+ */
+
+# include <mln/core/internal/pixel_iterator_base.hh>
+# include <mln/core/point1d.hh>
+# include <mln/geom/size1d.hh>
+
+
+
+namespace mln
+{
+
+ template <typename I>
+ class fwd_pixter1d_b : public internal::pixel_iterator_base_< I, fwd_pixter1d_b<I> >
+ {
+ typedef internal::pixel_iterator_base_< I, fwd_pixter1d_b<I> > super_;
+
+ public:
+
+ /// Image type.
+ typedef I image;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] image Image to iterate over its pixels.
+ */
+ fwd_pixter1d_b(I& image);
+
+ /// Go to the next pixel.
+ void next_();
+
+ };
+
+
+ // FIXME: bkd_pixter1d_b
+
+
+#ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ fwd_pixter1d_b<I>::fwd_pixter1d_b(I& image) :
+ super_(image)
+ {
+ mln_precondition(image.has_data());
+ }
+
+ template <typename I>
+ void
+ fwd_pixter1d_b<I>::next_()
+ {
+ ++this->value_ptr_;
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_PIXTER1D_B_HH
Index: trunk/milena/mln/core/box1d.hh
===================================================================
--- trunk/milena/mln/core/box1d.hh (revision 0)
+++ trunk/milena/mln/core/box1d.hh (revision 1071)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_BOX1D_HH
+# define MLN_CORE_BOX1D_HH
+
+/*! \file mln/core/box1d.hh
+ *
+ * \brief Definition of the mln::box1d alias and of construction
+ * routines.
+ */
+
+# include <mln/core/box.hh>
+# include <mln/core/point1d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a box defined on the 1D square grid with
+ * integer coordinates.
+ *
+ * \see mln::win::rectangle1d.
+ */
+ typedef box_<point1d> box1d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/box1d.hh>
+
+
+#endif // ! MLN_CORE_BOX1D_HH
Index: trunk/milena/mln/core/point1d.hh
===================================================================
--- trunk/milena/mln/core/point1d.hh (revision 0)
+++ trunk/milena/mln/core/point1d.hh (revision 1071)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_POINT1D_HH
+# define MLN_CORE_POINT1D_HH
+
+/*! \file mln/core/point1d.hh
+ *
+ * \brief Definition of the mln::point1d alias and of its construction
+ * routine.
+ */
+
+# include <mln/core/point.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a point defined on the 1D square grid with
+ * integer coordinates.
+ */
+ typedef point_<1,int> point1d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/point1d.hh>
+# include <mln/core/dpoint1d.hh>
+
+
+#endif // ! MLN_CORE_POINT1D_HH
Index: trunk/milena/mln/core/internal/box_impl.hh
===================================================================
--- trunk/milena/mln/core/internal/box_impl.hh (revision 1070)
+++ trunk/milena/mln/core/internal/box_impl.hh (revision 1071)
@@ -77,6 +77,19 @@
C max_col() const;
};
+ template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
+ struct box_impl_<1, C, E>
+ {
+ /// Give the number of inds.
+ unsigned ninds() const;
+
+ /// Give the minimum ind.
+ C min_ind() const;
+
+ /// Give the minimum ind.
+ C max_ind() const;
+ };
+
# ifndef MLN_INCLUDE_ONLY
@@ -120,6 +133,26 @@
return internal::force_exact<E>(*this).bbox().pmax()[1];
}
+ // 1
+
+ template <typename C, typename E>
+ unsigned box_impl_<1, C, E>::ninds() const
+ {
+ return internal::force_exact<E>(*this).bbox().len(0);
+ }
+
+ template <typename C, typename E>
+ C box_impl_<1, C, E>::min_ind() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmin()[0];
+ }
+
+ template <typename C, typename E>
+ C box_impl_<1, C, E>::max_ind() const
+ {
+ return internal::force_exact<E>(*this).bbox().pmax()[0];
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::internal
Index: trunk/milena/mln/core/window1d.hh
===================================================================
--- trunk/milena/mln/core/window1d.hh (revision 0)
+++ trunk/milena/mln/core/window1d.hh (revision 1071)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WINDOW1D_HH
+# define MLN_CORE_WINDOW1D_HH
+
+/*! \file mln/core/window1d.hh
+ *
+ * \brief Definition of the mln::window1d alias and of a construction
+ * routine.
+ */
+
+# include <mln/core/window.hh>
+# include <mln/core/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a window with arbitrary shape, defined on
+ * the 1D square grid with integer coordinates.
+ */
+ typedef window<dpoint1d> window1d;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/window1d.hh>
+
+
+#endif // ! MLN_CORE_WINDOW1D_HH
Index: trunk/milena/mln/core/w_window1d_int.hh
===================================================================
--- trunk/milena/mln/core/w_window1d_int.hh (revision 0)
+++ trunk/milena/mln/core/w_window1d_int.hh (revision 1071)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_W_WINDOW1D_INT_HH
+# define MLN_CORE_W_WINDOW1D_INT_HH
+
+/*! \file mln/core/w_window1d_int.hh
+ *
+ * \brief Definition of the mln::w_window1d_int alias.
+ */
+
+# include <mln/core/w_window.hh>
+# include <mln/core/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a w_window with arbitrary shape, defined
+ * on the 1D grid (with integer coordinates) and whose
+ * weights are integers.
+ */
+ typedef w_window<dpoint1d, int> w_window1d_int;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/w_window1d.hh>
+
+
+#endif // ! MLN_CORE_W_WINDOW1D_INT_HH
Index: trunk/milena/mln/core/win/segment1d.hh
===================================================================
--- trunk/milena/mln/core/win/segment1d.hh (revision 0)
+++ trunk/milena/mln/core/win/segment1d.hh (revision 1071)
@@ -0,0 +1,181 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_WIN_SEGMENT1D_HH
+# define MLN_CORE_WIN_SEGMENT1D_HH
+
+/*! \file mln/core/win/segment1d.hh
+ *
+ * \brief Definition of the mln::win::segment1d window.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/dpoint1d.hh>
+# include <mln/core/dpoints_piter.hh>
+
+
+namespace mln
+{
+
+ namespace win
+ {
+
+ /*! \brief Segment window defined on the 1D grid.
+ *
+ * An segment1d is centered and symmetrical; so
+ * its height (length) is odd.
+ *
+ * For instance: \n
+ * o x o \n
+ * is defined with length = 3.
+ */
+ struct segment1d : public Window< segment1d >,
+ public internal::dpoints_base_< dpoint1d, segment1d >
+ {
+ /// Point associated type.
+ typedef point1d point;
+
+ /// Dpoint associated type.
+ typedef dpoint1d dpoint;
+
+ /*! \brief Point_Iterator type to browse a segment such as: "for each row
+ * (increasing), for each column (increasing)."
+ */
+ typedef dpoints_fwd_piter<dpoint1d> fwd_qiter;
+
+ /*! \brief Point_Iterator type to browse a segment such as: "for each row
+ * (decreasing), for each column (decreasing)."
+ */
+ typedef dpoints_bkd_piter<dpoint1d> bkd_qiter;
+
+ /*! \brief Same as fwd_qiter.
+ */
+ typedef fwd_qiter qiter;
+
+ /*! \brief Constructor.
+ *
+ * \param[in] length Length, thus height, of the segment1d.
+ *
+ * \pre \p length is odd.
+ */
+ segment1d(unsigned length);
+
+ /*! \brief Test if the window is centered.
+ *
+ * \return True.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test if the window is symmetric.
+ *
+ * \return true.
+ */
+ bool is_symmetric() const;
+
+ /*! \brief Give the segment length, that is, its height.
+ */
+ unsigned length() const;
+
+ /*! \brief Give the maximum coordinate gap between the window
+ * center and a window point.
+ */
+ unsigned delta() const;
+
+ /// Apply a central symmetry to the target window.
+ segment1d& sym();
+
+ protected:
+ unsigned length_;
+ };
+
+
+ /*! \brief Print a segment1D window \p win into the output
+ * stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] win A segment1D window.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::win::segment1d
+ */
+ std::ostream& operator<<(std::ostream& ostr, const segment1d& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ segment1d::segment1d(unsigned length)
+ : length_(length)
+ {
+ mln_precondition(length % 2 == 1);
+ const int dind = length / 2;
+ for (int ind = - dind; ind <= dind; ++ind)
+ insert(make::dpoint1d(ind));
+ }
+
+ bool segment1d::is_centered() const
+ {
+ return true;
+ }
+
+ bool segment1d::is_symmetric() const
+ {
+ return true;
+ }
+
+ unsigned segment1d::length() const
+ {
+ return length_;
+ }
+
+ unsigned segment1d::delta() const
+ {
+ return length_ / 2;
+ }
+
+ segment1d& segment1d::sym()
+ {
+ return *this;
+ }
+
+ std::ostream& operator<<(std::ostream& ostr, const segment1d& win)
+ {
+ ostr << "[segment1d: length=" << win.length() << ']';
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::win
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_WIN_SEGMENT1D_HH
Index: trunk/milena/mln/core/w_window1d_float.hh
===================================================================
--- trunk/milena/mln/core/w_window1d_float.hh (revision 0)
+++ trunk/milena/mln/core/w_window1d_float.hh (revision 1071)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_W_WINDOW1D_FLOAT_HH
+# define MLN_CORE_W_WINDOW1D_FLOAT_HH
+
+/*! \file mln/core/w_window1d_float.hh
+ *
+ * \brief Definition of the mln::w_window1d_float alias.
+ */
+
+# include <mln/core/w_window.hh>
+# include <mln/core/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Type alias for a w_window with arbitrary shape, defined
+ * on the 1D grid (with integer coordinates) and whose
+ * weights are floating values.
+ */
+ typedef w_window<dpoint1d, float> w_window1d_float;
+
+
+} // end of namespace mln
+
+
+# include <mln/make/w_window1d.hh>
+
+
+#endif // ! MLN_CORE_W_WINDOW1D_FLOAT_HH
Index: trunk/milena/mln/core/image1d_b.hh
===================================================================
--- trunk/milena/mln/core/image1d_b.hh (revision 0)
+++ trunk/milena/mln/core/image1d_b.hh (revision 1071)
@@ -0,0 +1,516 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE1D_B_HH
+# define MLN_CORE_IMAGE1D_B_HH
+
+/*! \file mln/core/image1d_b.hh
+ *
+ * \brief Definition of the basic mln::image1d_b class.
+ */
+
+# include <mln/core/internal/image_base.hh>
+# include <mln/core/box1d.hh>
+
+# include <mln/border/thickness.hh>
+# include <mln/value/set.hh>
+# include <mln/fun/i2v/all.hh>
+
+
+// FIXME:
+
+// # include <mln/core/pixter1d_b.hh>
+// # include <mln/core/dpoints_pixter.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename T> struct image1d_b;
+
+
+ namespace trait
+ {
+
+ template <typename T>
+ struct is_fast< image1d_b<T> >
+ {
+ typedef metal::true_ ret;
+ };
+
+ } // end of mln::trait
+
+
+
+ /*! \brief Basic 1D image class.
+ *
+ * The parameter \c T is the type of pixel values. This image class
+ * stores data in memory and has a virtual border with constant
+ * thickness around data.
+ */
+ template <typename T>
+ struct image1d_b : public internal::image_base_< box1d, image1d_b<T> >
+ {
+ // Warning: just to make effective types appear in Doxygen:
+ typedef box1d pset;
+ typedef point1d psite;
+ typedef point1d point;
+ typedef dpoint1d dpoint;
+ typedef mln_fwd_piter(box1d) fwd_piter;
+ typedef mln_bkd_piter(box1d) bkd_piter;
+ // End of warning.
+
+
+ /// Value associated type.
+ typedef T value;
+
+ /// Return type of read-only access.
+ typedef const T& rvalue;
+
+ /// Return type of read-write access.
+ typedef T& lvalue;
+
+ /// Change value type.
+ template <typename U>
+ struct change_value
+ {
+ typedef image1d_b<U> ret;
+ };
+
+ /// Value_Set associated type.
+ typedef mln::value::set<T> vset;
+
+
+ /// Constructor without argument.
+ image1d_b();
+
+ /// Constructor with the numbers of indexes and the
+ /// border thickness.
+ image1d_b(int ninds, unsigned bdr = border::thickness);
+
+ /// Constructor with a box and the border thickness (default is
+ /// 3).
+ image1d_b(const box1d& b, unsigned bdr = border::thickness);
+
+ /// Copy constructor.
+ image1d_b(const image1d_b<T>& rhs);
+
+ /// Assignment operator.
+ image1d_b& operator=(const image1d_b<T>& rhs);
+
+ /// Destructor.
+ ~image1d_b();
+
+
+ /// Initialize an empty image.
+ void init_with(int ninds, unsigned bdr = border::thickness);
+
+ /// Initialize an empty image.
+ void init_with(const box1d& b, unsigned bdr = border::thickness);
+
+
+ /// Test if \p p is valid.
+ bool owns_(const point1d& p) const;
+
+ /// Test if this image has been initialized.
+ bool has_data() const;
+
+ /// Give the set of values of the image.
+ const vset& values() const;
+
+ /// Give the definition domain.
+ const box1d& domain() const;
+
+ /// Give the border thickness.
+ unsigned border() const;
+
+ /// Give the number of cells (points including border ones).
+ std::size_t ncells() const;
+
+ /// Read-only access to the image value located at point \p p.
+ const T& operator()(const point1d& p) const;
+
+ /// Read-write access to the image value located at point \p p.
+ T& operator()(const point1d& p);
+
+ /// Read-only access to the image value located at offset \p o.
+ const T& operator[](unsigned o) const;
+
+ /// Read-write access to the image value located at offset \p o.
+ T& operator[](unsigned o);
+
+ /// Read-only access to the image value located at (\p ind).
+ const T& at(int ind) const;
+
+ /// Read-write access to the image value located at (\p ind).
+ T& at(int ind);
+
+
+ /// Fast Image method
+
+ /// Give the offset corresponding to the delta-point \p dp.
+ int offset(const dpoint1d& dp) const;
+
+ /// Give the point corresponding to the offset \p o.
+ point1d point_at_offset(unsigned o) const;
+
+ /// Give a hook to the value buffer.
+ const T* buffer() const;
+
+ /// Give a hook to the value buffer.
+ T* buffer();
+
+
+ private:
+
+ T* buffer_;
+
+ box1d b_; // theoretical box
+ unsigned bdr_;
+ box1d vb_; // virtual box, i.e., box including the virtual border
+
+ void update_vb_();
+ void allocate_();
+ void deallocate_();
+
+ typedef internal::image_base_< box1d, image1d_b<T> > super;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // ctors
+
+ template <typename T>
+ image1d_b<T>::image1d_b()
+ : buffer_(0)
+ {
+ bdr_ = border::thickness; // default value in ctors.
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(int ninds, unsigned bdr)
+ : buffer_(0)
+ {
+ init_with(ninds, bdr);
+ }
+
+ template <typename T>
+ void
+ image1d_b<T>::init_with(int ninds, unsigned bdr)
+ {
+ mln_precondition(! this->has_data());
+ b_ = make::box1d(ninds);
+ bdr_ = bdr;
+ allocate_();
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(const box1d& b, unsigned bdr)
+ : buffer_(0)
+ {
+ init_with(b, bdr);
+ }
+
+ template <typename T>
+ void
+ image1d_b<T>::init_with(const box1d& b, unsigned bdr)
+ {
+ mln_precondition(! this->has_data());
+ b_ = b;
+ bdr_ = bdr;
+ allocate_();
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(const image1d_b<T>& rhs)
+ : super(rhs),
+ b_(rhs.domain()),
+ bdr_(rhs.border())
+ {
+ allocate_();
+ std::memcpy(this->buffer_,
+ rhs.buffer_,
+ ncells() * sizeof(T));
+ }
+
+ // assignment
+
+ template <typename T>
+ image1d_b<T>&
+ image1d_b<T>::operator=(const image1d_b<T>& rhs)
+ {
+ mln_precondition(rhs.has_data());
+ if (& rhs == this)
+ return *this;
+ if (this->has_data())
+ this->deallocate_();
+ this->b_ = rhs.domain();
+ this->bdr_ = rhs.border();
+ allocate_();
+ std::memcpy(this->buffer_,
+ rhs.buffer_,
+ ncells() * sizeof(T));
+ return *this;
+ }
+
+ // methods
+
+ template <typename T>
+ bool
+ image1d_b<T>::has_data() const
+ {
+ return buffer_ != 0;
+ }
+
+ template <typename T>
+ const typename image1d_b<T>::vset&
+ image1d_b<T>::values() const
+ {
+ return vset::the();
+ }
+
+ template <typename T>
+ const box1d&
+ image1d_b<T>::domain() const
+ {
+ mln_precondition(this->has_data());
+ return b_;
+ }
+
+ template <typename T>
+ unsigned
+ image1d_b<T>::border() const
+ {
+ mln_precondition(this->has_data());
+ return bdr_;
+ }
+
+ template <typename T>
+ std::size_t
+ image1d_b<T>::ncells() const
+ {
+ mln_precondition(this->has_data());
+ return vb_.npoints();
+ }
+
+ template <typename T>
+ bool
+ image1d_b<T>::owns_(const point1d& p) const
+ {
+ mln_precondition(this->has_data());
+ return vb_.has(p);
+ }
+
+ template <typename T>
+ const T&
+ image1d_b<T>::operator()(const point1d& p) const
+ {
+ mln_precondition(this->owns_(p));
+ return buffer_[p.ind()];
+ }
+
+ template <typename T>
+ T&
+ image1d_b<T>::operator()(const point1d& p)
+ {
+ mln_precondition(this->owns_(p));
+ return buffer_[p.ind()];
+ }
+
+ template <typename T>
+ const T&
+ image1d_b<T>::operator[](unsigned o) const
+ {
+ mln_precondition(o < ncells());
+ return *(buffer_ + o);
+ }
+
+ template <typename T>
+ T&
+ image1d_b<T>::operator[](unsigned o)
+ {
+ mln_precondition(o < ncells());
+ return *(buffer_ + o);
+ }
+
+ template <typename T>
+ const T&
+ image1d_b<T>::at(int ind) const
+ {
+ mln_precondition(this->owns_(make::point1d(ind)));
+ return buffer_[ind];
+ }
+
+ template <typename T>
+ T&
+ image1d_b<T>::at(int ind)
+ {
+ mln_precondition(this->owns_(make::point1d(ind)));
+ return buffer_[ind];
+ }
+
+ template <typename T>
+ image1d_b<T>::~image1d_b()
+ {
+ deallocate_();
+ }
+
+ template <typename T>
+ const T*
+ image1d_b<T>::buffer() const
+ {
+ mln_precondition(this->has_data());
+ return buffer_;
+ }
+
+ template <typename T>
+ T*
+ image1d_b<T>::buffer()
+ {
+ mln_precondition(this->has_data());
+ return buffer_;
+ }
+
+ template <typename T>
+ int
+ image1d_b<T>::offset(const dpoint1d& dp) const
+ {
+ mln_precondition(this->has_data());
+ int o = dp[0];
+ return o;
+ }
+
+ template <typename T>
+ point1d
+ image1d_b<T>::point_at_offset(unsigned o) const
+ {
+ mln_precondition(o < ncells());
+ point1d p = make::point1d(o);
+ mln_postcondition(& this->operator()(p) == this->buffer_ + o);
+ return p;
+ }
+
+
+ // private
+
+ template <typename T>
+ void
+ image1d_b<T>::update_vb_()
+ {
+ vb_.pmin() = b_.pmin() - dpoint1d(all(bdr_));
+ vb_.pmax() = b_.pmax() + dpoint1d(all(bdr_));
+ }
+
+ template <typename T>
+ void
+ image1d_b<T>::allocate_()
+ {
+ update_vb_();
+ unsigned
+ ni = vb_.len(0);
+ buffer_ = new T[ni];
+ mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_);
+ }
+
+ template <typename T>
+ void
+ image1d_b<T>::deallocate_()
+ {
+ if (buffer_)
+ {
+ delete[] buffer_;
+ buffer_ = 0;
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/trait/pixter.hh>
+# include <mln/core/dpoints_pixter.hh>
+# include <mln/core/pixter1d_b.hh>
+# include <mln/core/w_window.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ // pixter
+
+ template <typename T>
+ struct fwd_pixter< image1d_b<T> >
+ {
+ typedef fwd_pixter1d_b< image1d_b<T> > ret;
+ };
+
+ template <typename T>
+ struct fwd_pixter< const image1d_b<T> >
+ {
+ typedef fwd_pixter1d_b< const image1d_b<T> > ret;
+ };
+
+ template <typename T>
+ struct bkd_pixter< image1d_b<T> >
+ {
+ typedef internal::fixme ret;
+ };
+
+ // qixter
+
+ template <typename T, typename W>
+ struct fwd_qixter< image1d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< image1d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct fwd_qixter< const image1d_b<T>, W >
+ {
+ typedef dpoints_fwd_pixter< const image1d_b<T> > ret;
+ };
+
+ template <typename T, typename W>
+ struct bkd_qixter< image1d_b<T>, W >
+ {
+ typedef internal::fixme ret;
+ };
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE1D_B_HH
Index: trunk/milena/mln/make/dpoint1d.hh
===================================================================
--- trunk/milena/mln/make/dpoint1d.hh (revision 0)
+++ trunk/milena/mln/make/dpoint1d.hh (revision 1071)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 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_MAKE_DPOINT1D_HH
+# define MLN_MAKE_DPOINT1D_HH
+
+/*! \file mln/make/dpoint1d.hh
+ *
+ * \brief Routine to construct an mln::dpoint1d.
+ */
+
+# include <mln/core/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::dpoint1d.
+ *
+ * \param[in] ind Ind coordinate.
+ *
+ * \return A 1D dpoint.
+ */
+ mln::dpoint1d dpoint1d(int ind);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::dpoint1d dpoint1d(int ind)
+ {
+ mln::dpoint1d tmp;
+ tmp[0] = ind;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_DPOINT1D_HH
Index: trunk/milena/mln/make/w_window1d.hh
===================================================================
--- trunk/milena/mln/make/w_window1d.hh (revision 0)
+++ trunk/milena/mln/make/w_window1d.hh (revision 1071)
@@ -0,0 +1,86 @@
+// Copyright (C) 2007 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_MAKE_W_WINDOW1D_HH
+# define MLN_MAKE_W_WINDOW1D_HH
+
+/*! \file mln/make/w_window1d.hh
+ *
+ * \brief Routine to create an mln::w_window in the 1D case.
+ */
+
+# include <cmath>
+
+# include <mln/core/w_window.hh>
+# include <mln/core/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create a 1D mln::w_window from an array of weights.
+ *
+ * \param[in] weights Array.
+ *
+ * \pre The array size, \c M, has to be a square of an odd integer.
+ *
+ * \return A 1D weighted window.
+ */
+ template <typename W, unsigned M>
+ mln::w_window<mln::dpoint1d, W> w_window1d(W (&weights)[M]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename W, unsigned M>
+ mln::w_window<mln::dpoint1d, W>
+ w_window1d(W (&weights)[M])
+ {
+ int h = M / 2;
+ mln_precondition(1 == (M % 1));
+ mln::w_window<mln::dpoint1d, W> tmp;
+ unsigned i = 0;
+ for (int ind = - h; ind <= h; ++ind)
+ {
+ if (weights[i] != 0)
+ tmp.insert(weights[i], make::dpoint1d(ind));
+ i++;
+ }
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_W_WINDOW1D_HH
Index: trunk/milena/mln/make/w_window1d_int.hh
===================================================================
--- trunk/milena/mln/make/w_window1d_int.hh (revision 0)
+++ trunk/milena/mln/make/w_window1d_int.hh (revision 1071)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007 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_MAKE_W_WINDOW1D_INT_HH
+# define MLN_MAKE_W_WINDOW1D_INT_HH
+
+/*! \file mln/make/w_window1d_int.hh
+ *
+ * \brief Routine to create a mln::w_window1d_int.
+ */
+
+# include <mln/core/w_window1d_int.hh>
+# include <mln/make/w_window1d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create a mln::w_window1d_int.
+ *
+ * \param[in] weights Array of integers.
+ *
+ * \pre The array size, \c M, has to be a square of an odd integer.
+ *
+ * \return A 1D int-weighted window.
+ */
+ template <unsigned M>
+ mln::w_window1d_int w_window1d_int(int (&weights)[M]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned M>
+ mln::w_window1d_int
+ w_window1d_int(int (&weights)[M])
+ {
+ mln_precondition(1 == (M % 2));
+ return make::w_window1d(weights);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_W_WINDOW1D_INT_HH
Index: trunk/milena/mln/make/window1d.hh
===================================================================
--- trunk/milena/mln/make/window1d.hh (revision 0)
+++ trunk/milena/mln/make/window1d.hh (revision 1071)
@@ -0,0 +1,81 @@
+// Copyright (C) 2007 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_MAKE_WINDOW1D_HH
+# define MLN_MAKE_WINDOW1D_HH
+
+/*! \file mln/make/window1d.hh
+ *
+ * \brief Routine to create an mln::window1d.
+ */
+
+# include <cmath>
+# include <mln/core/window1d.hh>
+# include <mln/make/dpoint1d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::window1d.
+ *
+ * \param[in] values Array of Booleans.
+ *
+ * \pre The array size, \c M, has to be a line of an odd integer.
+ *
+ * \return A 1D window.
+ */
+ template <unsigned M>
+ mln::window1d window1d(bool (&values)[M]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned M>
+ mln::window1d window1d(bool (&values)[M])
+ {
+ int h = M / 2;
+ assert((M % 2) == 1);
+ mln::window1d tmp;
+ unsigned i = 0;
+ for (int ind = - h; ind <= h; ++ind)
+ if (values[i++])
+ tmp.insert(make::dpoint1d(ind));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_WINDOW1D_HH
Index: trunk/milena/mln/make/box1d.hh
===================================================================
--- trunk/milena/mln/make/box1d.hh (revision 0)
+++ trunk/milena/mln/make/box1d.hh (revision 1071)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 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_MAKE_BOX1D_HH
+# define MLN_MAKE_BOX1D_HH
+
+/*! \file mln/make/box1d.hh
+ *
+ * \brief Routines to construct an mln::box1d.
+ */
+
+# include <mln/core/box1d.hh>
+# include <mln/make/point1d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::box1d.
+ *
+ * \param[in] ninds Number of inds.
+ *
+ * \pre \p ninds != 0 and \p ncols != 0.
+ *
+ * \return A 1D box.
+ */
+ mln::box1d box1d(unsigned ninds);
+
+
+ /*! \brief Create an mln::box1d.
+ *
+ * \overload
+ *
+ * \param[in] min_ind Index of the top most ind.
+ * \param[in] max_ind Index of the botton most ind.
+ *
+ * \pre \p max_ind >= \p min_ind.
+ *
+ * \return A 1D box.
+ */
+ mln::box1d box1d(int min_ind, int max_ind);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::box1d box1d(unsigned ninds)
+ {
+ mln_precondition(ninds != 0);
+ mln::box1d tmp(make::point1d(0),
+ make::point1d(ninds - 1));
+ return tmp;
+ }
+
+ mln::box1d box1d(int min_ind, int max_ind)
+ {
+ mln_precondition(max_ind >= min_ind);
+ mln::box1d tmp(make::point1d(min_ind),
+ make::point1d(max_ind));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_BOX1D_HH
Index: trunk/milena/mln/make/point1d.hh
===================================================================
--- trunk/milena/mln/make/point1d.hh (revision 0)
+++ trunk/milena/mln/make/point1d.hh (revision 1071)
@@ -0,0 +1,71 @@
+// Copyright (C) 2007 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_MAKE_POINT1D_HH
+# define MLN_MAKE_POINT1D_HH
+
+/*! \file mln/make/point1d.hh
+ *
+ * \brief Routine to construct an mln::point1d.
+ */
+
+# include <mln/core/point1d.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /*! \brief Create an mln::point1d.
+ *
+ * \param[in] ind Ind coordinate.
+ * \param[in] col Column coordinate.
+ *
+ * \return A 1D point.
+ */
+ mln::point1d point1d(int ind);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ mln::point1d point1d(int ind)
+ {
+ mln::point1d tmp;
+ tmp[0] = ind;
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_POINT1D_HH
Index: trunk/milena/sandbox/garrigues/TODO
===================================================================
--- trunk/milena/sandbox/garrigues/TODO (revision 0)
+++ trunk/milena/sandbox/garrigues/TODO (revision 1071)
@@ -0,0 +1,22 @@
+C R core/box1d.hh
+C R core/dpoint1d.hh
+C R core/image1d_b.hh
+INUTILE R core/line1d.hh
+C R core/neighb1d.hh
+C R core/pixter1d_b.hh
+C R core/point1d.hh
+C R core/window1d.hh
+
+R core/win/hline1d.hh |
+R core/win/rectangle1d.hh |-> C segment1d.hh
+R core/win/vline1d.hh |
+
+C R core/w_window1d_float.hh
+C R core/w_window1d_int.hh
+C R geom/size1d.hh
+C R make/box1d.hh
+C R make/dpoint1d.hh
+C R make/point1d.hh
+C R make/window1d.hh
+C R make/w_window1d.hh
+C R make/w_window1d_int.hh
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-05 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Fast gaussian works on 2d images
* sandbox/nivault/fast_gaussian.hh: .
* sandbox/nivault/tests/test.cc: .
fast_gaussian.hh | 25 +++++++++++++++++--------
tests/test.cc | 7 ++++---
2 files changed, 21 insertions(+), 11 deletions(-)
Index: trunk/milena/sandbox/nivault/tests/test.cc
===================================================================
--- trunk/milena/sandbox/nivault/tests/test.cc (revision 1069)
+++ trunk/milena/sandbox/nivault/tests/test.cc (revision 1070)
@@ -34,9 +34,10 @@
int main()
{
mln::image2d_b<mln::value::int_u<8u> > im1 = mln::io::load_pgm("../../../img/lena.pgm");
- mln::image2d_b<float> im2;
+ mln_precondition(im1.has_data());
+ mln::image2d_b<mln::value::int_u<8u> > im2(im1.domain());
- mln::linear::gaussian(im1, 0.2, im2);
+ mln::linear::gaussian(im1, 2, im2);
- // mln::io::save_pgm(im2, "gausslena.pgm");
+ mln::io::save_pgm(im2, "gausslena.pgm");
}
Index: trunk/milena/sandbox/nivault/fast_gaussian.hh
===================================================================
--- trunk/milena/sandbox/nivault/fast_gaussian.hh (revision 1069)
+++ trunk/milena/sandbox/nivault/fast_gaussian.hh (revision 1070)
@@ -30,7 +30,7 @@
#include <mln/core/concept/image.hh>
#include <mln/level/paste.hh>
-#include <mln/geom/ncols.hh>
+
namespace mln
@@ -178,7 +178,7 @@
+ c.n[3]*ima(current - d - d - d)
- c.d[1]*tmp1[i - 1] - c.d[2]*tmp1[i - 2]
- c.d[3]*tmp1[i - 3] - c.d[4]*tmp1[i - 4];
- current += d;
+ current = current + d;
}
// Non causal part
@@ -211,7 +211,7 @@
+ c.nm[4]*ima(current + d + d + d)
- c.dm[1]*tmp2[i+1] - c.dm[2]*tmp2[i+2]
- c.dm[3]*tmp2[i+3] - c.dm[4]*tmp2[i+4];
- current -= d;
+ current = current - d;
}
// Combine results from causal and non-causal parts.
@@ -220,7 +220,7 @@
for (int i = 0; i < len; ++i)
{
ima(current) = tmp1[i] + tmp2[i];
- current += d;
+ current = current + d;
}
}
@@ -230,14 +230,23 @@
gaussian_(Image<I>& img_, const F& coef)
{
I& img = exact(img_);
- typedef mln_point(I) P;
- // Apply on columns.
+ // Apply on rows.
+ for (int j = 0; j < geom::ncols(img); ++j)
+ recursivefilter_<float>(img, coef,
+ make::point2d(-img.border(), j),
+ make::point2d(geom::nrows(img) - 1 + img.border(), j),
+ geom::nrows(img) + 2 * img.border(),
+ make::dpoint2d(1, 0));
+
+ // Apply on columns.
+ for (int i = 0; i < geom::nrows(img); ++i)
recursivefilter_<float>(img, coef,
- make::point2d(0, - img.border()), // FIXME
- make::point2d(0, geom::ncols(img) - 1 + img.border()),
+ make::point2d(i, -img.border()),
+ make::point2d(i, geom::ncols(img) - 1 + img.border()),
geom::ncols(img) + 2 * img.border(),
make::dpoint2d(0, 1));
+
}
1
0