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
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix mln/accu/maj_h.hh.
* mln/accu/maj_h.hh: Add critical update.
maj_h.hh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: mln/accu/maj_h.hh
--- mln/accu/maj_h.hh (revision 2816)
+++ mln/accu/maj_h.hh (working copy)
@@ -158,7 +158,8 @@
{
h_.take(other.h_);
- //FIXME: t_ is wrong then
+ if (valid_)
+ valid_ = false;
}
template <typename T>
1
0
05 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Update some files and add test suite for nature.
* abraham/tests/core/image/thru_v2v.cc,
abraham/tests/core/image/thru_const.cc:
make::image2d to make::image .
* abraham/mln/level/transform.hh: Remove.
* abraham/mln/core/image/shell.hh: Remove.
* abraham/mln/fun/meta/to_enc.hh: New
Make this functor meta.
* abraham/mln/fun/v2v/rgb_to_hsi.hh:
Corrected version of rgb to hsi conversion.
* abraham/mln/binarization/binarization.hh: Remove.
* abraham/mln/transform: New.
* abraham/mln/transform/fft.hh: New.
* abraham/mln/value/shell.hh:
Support Function_v2v.
* nature/histo_hsi.cc: .
* nature/hom.cc: .
* nature/mco.cc: .
* nature/nature.cc: New.
* nature/opening.cc: .
* nature/test.sh: New.
abraham/mln/binarization/binarization.hh | 106 ----
abraham/mln/core/image/shell.hh | 157 -------
abraham/mln/fun/meta/to_enc.hh | 57 ++
abraham/mln/fun/v2v/rgb_to_hsi.hh | 8
abraham/mln/level/transform.hh | 209 ---------
abraham/mln/transform/fft.hh | 681 +++++++++++++++++++++++++++++++
abraham/mln/value/shell.hh | 2
abraham/tests/core/image/thru_const.cc | 2
abraham/tests/core/image/thru_v2v.cc | 2
nature/histo_hsi.cc | 34 +
nature/hom.cc | 224 ++++++++--
nature/mco.cc | 4
nature/nature.cc | 408 ++++++++++++++++++
nature/opening.cc | 2
nature/test.sh | 11
15 files changed, 1377 insertions(+), 530 deletions(-)
Index: abraham/tests/core/image/thru_v2v.cc
--- abraham/tests/core/image/thru_v2v.cc (revision 2815)
+++ abraham/tests/core/image/thru_v2v.cc (working copy)
@@ -47,7 +47,7 @@
};
- image2d<int> ima(make::image2d(vs));
+ image2d<int> ima(make::image(vs));
thru<mln::fun::v2v::abs<int>, image2d<int> > out(ima);
box_fwd_piter_<point2d> p(ima.domain());
Index: abraham/tests/core/image/thru_const.cc
--- abraham/tests/core/image/thru_const.cc (revision 2815)
+++ abraham/tests/core/image/thru_const.cc (working copy)
@@ -47,7 +47,7 @@
};
- I ima(make::image2d(vs));
+ I ima(make::image(vs));
thru<mln::fun::v2w2v::cos<double>, I > out(ima);
double i = 0;
Index: abraham/mln/fun/meta/to_enc.hh
--- abraham/mln/fun/meta/to_enc.hh (revision 0)
+++ abraham/mln/fun/meta/to_enc.hh (revision 0)
@@ -0,0 +1,57 @@
+// 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_FUN_META_RED_HH
+# define MLN_FUN_META_RED_HH
+
+# include <mln/core/concept/meta_fun.hh>
+
+namespace mln {
+
+ namespace meta {
+
+ template <class T>
+ struct to_enc : impl< to_enc<T> > { typedef typename T::enc value; };
+
+ };
+
+ template <typename T>
+ struct function< meta::to_enc<T> > : public Function_v2v<function< meta::to_enc<T> > >
+ {
+ typedef typename T::enc value;
+
+ value read(const T& t)
+ {
+ return t.to_enc();
+ }
+
+ };
+
+
+};
+
+#endif // MLN_FUN_META_RED_HH
Index: abraham/mln/fun/v2v/rgb_to_hsi.hh
--- abraham/mln/fun/v2v/rgb_to_hsi.hh (revision 2815)
+++ abraham/mln/fun/v2v/rgb_to_hsi.hh (working copy)
@@ -83,7 +83,7 @@
// sqrt3_3 * rgb.green() +
// sqrt3_3 * rgb.blue();
- hsi.inty() = (rgb.red() + rgb.green() + rgb.blue()) / 3;
+ hsi.inty() = (double) (rgb.red() + rgb.green() + rgb.blue()) / 3 / mln_max(typename T_rgb::red_t);
typename T_rgb::red_t min = rgb.red();
if (rgb.green() < min)
@@ -94,18 +94,18 @@
if (hsi.inty())
- hsi.sat() = (1 - (double) 3 * min / (double)(rgb.red() + rgb.green() + rgb.blue())) * 100;
+ hsi.sat() = (1 - (double) 3 * min / (double)(rgb.red() + rgb.green() + rgb.blue()));
else
hsi.sat() = 0; // this is black for any value of saturation
if (hsi.sat())
hsi.hue() = acos( 0.5 * (2 * rgb.red() - rgb.green() - rgb.blue()) /
- std::sqrt((rgb.red() - rgb.green()) * (rgb.red() - rgb.green()) + (rgb.red() - rgb.blue()) * (rgb.green() - rgb.blue()))) / 3.1415 * 180.0;
+ std::sqrt((rgb.red() - rgb.green()) * (rgb.red() - rgb.green()) + (rgb.red() - rgb.blue()) * (rgb.green() - rgb.blue()))) / 3.1416;
else
hsi.hue() = 0; // this is grey for any value of hue
if (hsi.hue() < 0)
- hsi.hue() = hsi.hue() + 360.0;
+ hsi.hue() = hsi.hue() + 1.0;
mln_invariant(hsi.hue() >= 0);
mln_invariant(hsi.hue() < 360);
Index: abraham/mln/transform/fft.hh
--- abraham/mln/transform/fft.hh (revision 0)
+++ abraham/mln/transform/fft.hh (revision 0)
@@ -0,0 +1,681 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRANSFORM_FFT_HH
+# define MLN_TRANSFORM_FFT_HH
+
+# ifdef HAVE_FFTW
+
+# include <fftw.h>
+# include <rfftw.h>
+
+namespace mln {
+
+ namespace internal {
+
+ /// Dispatch traits for fftw
+ enum fft_dispatch { fft_cplx, fft_real };
+
+ /*!
+ ** \brief fft trait.
+ */
+ template <class T>
+ struct fft_trait
+ {
+ void ensure() { ntg_is_a(T, ntg::real)::ensure(); }
+
+ static const fft_dispatch which = fft_real; ///< Real dispatch.
+ typedef fftw_real fftw_input; ///< Type of input.
+ };
+
+ /*!
+ ** \brief fft trait.
+ **
+ ** \specialization for ntg::cplx<R, T>
+ */
+ template <ntg::cplx_representation R, class T>
+ struct fft_trait<ntg::cplx<R, T> >
+ {
+ static const fft_dispatch which = fft_cplx; ///< Complex dispatch.
+ typedef fftw_complex fftw_input; ///< Type of input.
+ };
+
+ /*!
+ ** _fft<ntg::cplx_representation, T>
+ **
+ ** \param T Data type.
+ ** \param R type of representation.
+ */
+ template <class T, ntg::cplx_representation R>
+ class _fft
+ {
+ public:
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** Const version.
+ */
+ const image2d<ntg::cplx<R, ntg::float_d> > transformed_image() const
+ {
+ return trans_im;
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** Non const version.
+ */
+ image2d<ntg::cplx<R, ntg::float_d> >& transformed_image()
+ {
+ return trans_im;
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** |T[p]|.
+ **
+ ** \param T1 Data type of the resulting image.
+ **
+ ** \arg ordered Kind of traversal.
+ */
+ template <class T1>
+ image2d<T1> transformed_image_magn(bool ordered = true) const
+ {
+ ntg_is_a(T1, ntg::real)::ensure();
+
+ image2d<T1> new_im(trans_im.size());
+
+ if (ordered)
+ for (int row = 0; row < new_im.nrows(); ++row)
+ for (int col = 0; col < new_im.ncols(); ++col)
+ new_im(row, col) =
+ trans_im((row + trans_im.nrows() / 2) % trans_im.nrows(),
+ (col + trans_im.ncols() / 2) % trans_im.ncols()).magn();
+ else
+ {
+ typename image2d<ntg::cplx<R, ntg::float_d> >::iter it(trans_im);
+
+ for_all(it)
+ new_im[it] = trans_im[it].magn();
+ }
+
+ return new_im;
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** |T[p]|.
+ **
+ ** \arg ordered Kind of traversal.
+ */
+ image2d<T> transformed_image_magn(bool ordered = true) const
+ {
+ return transformed_image_magn<T>(ordered);
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a clipped value of |T[p]|.\n
+ **
+ ** \param T1 Data type of the resulting image.
+ **
+ ** \arg clip Value used for clipping.
+ ** \arg ordered Kind of traversal.
+ */
+ template <class T1>
+ image2d<T1> transformed_image_clipped_magn(const ntg::float_d clip,
+ bool ordered = true) const
+ {
+ ntg_is_a(T1, ntg::real)::ensure();
+
+ image2d<T1> new_im(trans_im.size());
+ ntg::range<ntg::float_d, ntg::bounded_u<0, 1>, ntg::saturate> c(clip);
+ ntg::float_d max = 0;
+ typename image2d<ntg::cplx<R, ntg::float_d> >::iter_type it(trans_im);
+
+ for_all(it)
+ if (max < trans_im[it].magn())
+ max = trans_im[it].magn();
+
+ if (ordered)
+ for (int row = 0; row < new_im.nrows(); ++row)
+ for (int col = 0; col < new_im.ncols(); ++col)
+ {
+ if (trans_im((row + trans_im.nrows() / 2) % trans_im.nrows(),
+ (col + trans_im.ncols() / 2) %
+ trans_im.ncols()).magn() >= max * c)
+ new_im(row, col) = ntg_max_val(T);
+ else
+ new_im(row, col) =
+ ntg_max_val(T) *
+ trans_im((row + trans_im.nrows() / 2) % trans_im.nrows(),
+ (col + trans_im.ncols() / 2) %
+ trans_im.ncols()).magn() / (max * c);
+ }
+ else
+ for_all(it)
+ {
+ if (trans_im[it].magn() >= max * c)
+ new_im[it] = ntg_max_val(T);
+ else
+ new_im[it] = ntg_max_val(T) *
+ trans_im[it].magn() / (max * c);
+ }
+
+ return new_im;
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a clipped value of |T[p]|.\n
+ **
+ ** \arg clip Value used for clipping.
+ ** \arg ordered Kind of traversal.
+ */
+ image2d<T> transformed_image_clipped_magn(const ntg::float_d clip,
+ bool ordered = true) const
+ {
+ return transformed_image_clipped_magn<T>(clip, ordered);
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a clipped value of |T[p]|.\n
+ **
+ ** \param T1 Data type of the resulting image.
+ **
+ ** \arg ordered Kind of traversal.
+ */
+ template <class T1>
+ image2d<T1> transformed_image_clipped_magn(bool ordered = true) const
+ {
+ return transformed_image_clipped_magn<T1>(1, ordered);
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a clipped value of |T[p]|.\n
+ **
+ ** \param T1 Data type of the resulting image.
+ **
+ ** \arg ordered Kind of traversal.
+ */
+ image2d<T> transformed_image_clipped_magn(bool ordered = true) const
+ {
+ return transformed_image_clipped_magn<T>(1, ordered);
+ }
+
+ // FIXME: Find a more elegant way to fix range interval on a and b.
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a log translated value of |T[p]| on interval [a; b].\n
+ **
+ ** \arg a Lower bound.
+ ** \arg b Upper bound.
+ ** \arg ordered Kind of traversal.
+ */
+ template <class T1>
+ image2d<T1> transformed_image_log_magn(const ntg::range<ntg::float_d,
+ ntg::bounded_u<0, 1000>,
+ ntg::saturate> a,
+ const ntg::range<ntg::float_d,
+ ntg::bounded_u<0, 1000>,
+ ntg::saturate> b,
+ bool ordered = true) const
+ {
+ ntg_is_a(T1, ntg::real)::ensure();
+
+ image2d<T1> new_im(trans_im.size());
+ ntg::float_d max = 0;
+ typename image2d<ntg::cplx<R, ntg::float_d> >::iter_type it(trans_im);
+
+ for_all(it)
+ if (max < trans_im[it].magn())
+ max = trans_im[it].magn();
+
+ if (ordered)
+ for (int row = 0; row < new_im.nrows(); ++row)
+ for (int col = 0; col < new_im.ncols(); ++col)
+ new_im(row, col) =
+ log(a + b * trans_im((row + trans_im.nrows() / 2) %
+ trans_im.nrows(),
+ (col + trans_im.ncols() / 2) %
+ trans_im.ncols()).magn()) /
+ log(a + b * max) * ntg_max_val(T);
+ else
+ for_all(it)
+ new_im[it] = log(a + b * trans_im[it].magn()) /
+ log(a + b * max) * ntg_max_val(T);
+
+ return new_im;
+ }
+
+ // FIXME: Find a more elegant way to fix boundaries of a and b.
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a log translated value of |T[p]| on interval [a; b].\n
+ **
+ ** \arg a Lower bound.
+ ** \arg b Upper bound.
+ ** \arg ordered Kind of traversal.
+ */
+ image2d<T> transformed_image_log_magn(const ntg::range<ntg::float_d,
+ ntg::bounded_u<0, 1000>,
+ ntg::saturate> a,
+ const ntg::range<ntg::float_d,
+ ntg::bounded_u<0, 1000>,
+ ntg::saturate> b,
+ bool ordered = true) const
+ {
+ return transformed_image_log_magn<T>(a, b, ordered);
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a log translated value of |T[p]| on interval [1; 100].\n
+ **
+ ** \param T1 Data type of the resulting image.
+ **
+ ** \arg ordered Kind of traversal.
+ */
+ template <class T1>
+ image2d<T1> transformed_image_log_magn(bool ordered = true) const
+ {
+ return transformed_image_log_magn<T1>(1, 100, ordered);
+ }
+
+ /*!
+ ** \brief Accessor to transformed image.
+ **
+ ** For each point p of the transformed image T, you get
+ ** a log translated value of |T[p]| on interval [1; 100].\n
+ **
+ ** \arg ordered Kind of traversal.
+ */
+ image2d<T> transformed_image_log_magn(bool ordered = true) const
+ {
+ return transformed_image_log_magn<T>(1, 100, ordered);
+ }
+
+ /*!
+ ** \brief Destructor.
+ **
+ ** Let memory free for other big images !!!
+ */
+ ~_fft()
+ {
+ delete [] in;
+ delete [] out;
+ fftwnd_destroy_plan(p);
+ fftwnd_destroy_plan(p_inv);
+ }
+
+ protected:
+
+ typename fft_trait<T>::fftw_input *in; ///< Input image.
+ fftw_complex *out; ///< Complex image.
+ fftwnd_plan p; ///< Plan.
+ fftwnd_plan p_inv; ///< inverted plan.
+ image2d<ntg::cplx<R, ntg::float_d> > trans_im; ///< Transformed image.
+
+ };
+
+ } // end of namespace internal
+
+ namespace transforms {
+
+ /*!
+ ** \brief fft class declaration.
+ **
+ ** \param T Data type.
+ ** \param R Complex representation kind.
+ ** \param which Dispatch.
+ */
+ template <class T,
+ ntg::cplx_representation R = ntg::polar,
+ internal::fft_dispatch which = internal::fft_trait<T>::which >
+ class fft;
+
+ /*!
+ ** \brief fft specialization for fft real dispatch.
+ **
+ ** \param T Data type.
+ ** \param R Complex representation kind.
+ */
+ template <class T, ntg::cplx_representation R>
+ class fft<T, R, internal::fft_real> : public internal::_fft<T, R>
+ {
+
+ public:
+
+ /*!
+ ** \brief Constructor.
+ **
+ ** Initialization of data in order to compute the fft.
+ **
+ ** \arg original_im Image to process.
+ */
+ fft(const image2d<T>& original_im)
+ {
+ this->in = new fftw_real[original_im.nrows() * original_im.ncols()];
+ this->out = new fftw_complex[original_im.nrows() *
+ (original_im.ncols() / 2 + 1)];
+
+ for (int row = 0; row < original_im.nrows(); ++row)
+ for (int col = 0; col < original_im.ncols(); ++col)
+ this->in[row * original_im.ncols() + col] = original_im(row, col);
+
+ this->p = rfftw2d_create_plan(original_im.nrows(), original_im.ncols(),
+ FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE);
+ this->p_inv = rfftw2d_create_plan(original_im.nrows(), original_im.ncols(),
+ FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE);
+
+ this->trans_im = image2d<ntg::cplx<R, ntg::float_d> >(original_im.size());
+ }
+
+ /*!
+ ** \brief Compute and return the transform.
+ */
+ image2d<ntg::cplx<R, ntg::float_d> > transform()
+ {
+ rfftwnd_one_real_to_complex(this->p, this->in, this->out);
+
+ unsigned denom = this->trans_im.nrows() * this->trans_im.ncols();
+ int i = 0;
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = 0; col <= this->trans_im.ncols() / 2; ++col)
+ {
+ this->out[i].re /= denom;
+ this->out[i].im /= denom;
+ this->trans_im(row, col) = ntg::cplx<ntg::rect, ntg::float_d>(this->out[i].re,
+ this->out[i].im);
+ ++i;
+ }
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = this->trans_im.ncols() - 1; col > this->trans_im.ncols() / 2; --col)
+ this->trans_im(row, col) = this->trans_im(this->trans_im.nrows() - row - 1,
+ this->trans_im.ncols() - col - 1);
+ return this->trans_im;
+ }
+
+ /*!
+ ** \brief Compute and return the invert transform.
+ **
+ ** \param T1 Data type of output image.
+ */
+ template <class T1>
+ image2d<T1> transform_inv()
+ {
+ ntg_is_a(T1, ntg::real)::ensure();
+
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = 0; col <= this->trans_im.ncols() / 2; ++col)
+ {
+ this->out[row * (this->trans_im.ncols() / 2 + 1) + col].re =
+ this->trans_im(row, col).real();
+ this->out[row * (this->trans_im.ncols() / 2 + 1) + col].im =
+ this->trans_im(row, col).imag();
+ }
+ rfftwnd_one_complex_to_real(this->p_inv, this->out, this->in);
+
+ image2d<T1> new_im(this->trans_im.size());
+ int i = 0;
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = 0; col < this->trans_im.ncols(); ++col)
+ {
+ new_im(row, col) = (this->in[i] >= ntg_inf_val(T1) ?
+ (this->in[i] <= ntg_sup_val(T1) ?
+ this->in [i] :
+ ntg_sup_val(T1)) :
+ ntg_inf_val(T1));
+ ++i;
+ }
+ return new_im;
+ }
+
+ /*!
+ ** \brief Shift zero-frequency component of discrete Fourier transform
+ ** to center of spectrum.
+ **
+ ** \param T1 The data type of the image returned.
+ **
+ ** The zero-frequency component of discrete Fourier transform are moved
+ ** to center of the image :
+ **
+ ** \htmlonly
+ ** <table>
+ ** <tr><td>1</td><td>2</td></tr>
+ ** <tr><td>3</td><td>4</td></tr>
+ ** </table>
+ ** becomes
+ ** <table>
+ ** <tr><td>4</td><td>3</td></tr>
+ ** <tr><td>2</td><td>1</td></tr>
+ ** </table>
+ ** \endhtmlonly
+ **
+ */
+ template <class T1>
+ image2d<T1> shift_transform_inv()
+ {
+ image2d<T1> t = transform_inv<T1>();
+ image2d<T1> st(t.size());
+
+ // We have to exchange t_1 with t_1_dest and not directly t_3 because
+ // they have not he same size.
+ typedef morpher::piece_morpher< image2d<T1> > piece_t;
+ piece_t t_1(t, dpoint2d(0, 0),
+ image2d_size((t.size().nrows() - 1) / 2,
+ (t.size().ncols() - 1) / 2,
+ t.border()));
+ piece_t t_1_dest(st, dpoint2d(t.nrows() - t_1.nrows(),
+ t.ncols() - t_1.ncols()),
+ image2d_size(t_1.nrows(), t_1.ncols(),
+ t.border()));
+ piece_t t_2(t, dpoint2d(0, (t.size().ncols() - 1) / 2),
+ image2d_size((t.size().nrows() - 1) / 2,
+ t.size().ncols() - (t.size().ncols() - 1) / 2,
+ t.border()));
+ piece_t t_2_dest(st, dpoint2d(t.nrows() - t_2.nrows(), 0),
+ image2d_size(t_2.nrows(), t_2.ncols(),
+ t.border()));
+ piece_t t_3(t, dpoint2d((t.size().nrows() - 1) / 2, 0),
+ image2d_size(t.size().nrows() - (t.size().nrows() - 1) / 2,
+ (t.size().ncols() - 1) / 2,
+ t.border()));
+ piece_t t_3_dest(st, dpoint2d(0, t.ncols() - t_3.ncols()),
+ image2d_size(t_3.nrows(), t_3.ncols(),
+ t.border()));
+ piece_t t_4(t, dpoint2d((t.size().nrows() - 1) / 2,
+ (t.size().ncols() - 1) / 2),
+ image2d_size(t.size().nrows() - (t.size().nrows() - 1) / 2,
+ t.size().ncols() - (t.size().ncols() - 1) / 2,
+ t.border()));
+ piece_t t_4_dest(st, dpoint2d(0, 0),
+ image2d_size(t_4.nrows(), t_4.ncols(),
+ t.border()));
+
+ oln_iter_type(piece_t) i1(t_1);
+ for_all(i1)
+ t_1_dest[i1] = t_1[i1];
+ oln_iter_type(piece_t) i2(t_2);
+ for_all(i2)
+ t_2_dest[i2] = t_2[i2];
+ oln_iter_type(piece_t) i3(t_3);
+ for_all(i3)
+ t_3_dest[i3] = t_3[i3];
+ oln_iter_type(piece_t) i4(t_4);
+ for_all(i4)
+ t_4_dest[i4] = t_4[i4];
+
+ return st;
+ }
+
+ /*!
+ ** \brief Compute and return the invert transform.
+ */
+ image2d<T> transform_inv()
+ {
+ return transform_inv<T>();
+ }
+
+ /*!
+ ** \brief Shift zero-frequency component of discrete Fourier transform
+ ** to center of spectrum.
+ */
+ image2d<T> shift_transform_inv()
+ {
+ return shift_transform_inv<T>();
+ }
+
+ };
+
+ /*!
+ ** \brief fft specialization for fft complex dispatch.
+ **
+ ** \param T Data type.
+ ** \param R Complex representation kind.
+ */
+ template <class T, ntg::cplx_representation R>
+ class fft<T, R, internal::fft_cplx> : public internal::_fft<T, R>
+ {
+
+ public:
+
+ /*!
+ ** \brief Constructor.
+ **
+ ** Initialization of data in order to compute the fft.
+ **
+ ** \arg original_im Image to process.
+ */
+ template <ntg::cplx_representation R1>
+ fft(const image2d<ntg::cplx<R1, T> >& original_im)
+ {
+ this->in = new fftw_complex[original_im.nrows() * original_im.ncols()];
+ this->out = new fftw_complex[original_im.nrows() * original_im.ncols()];
+
+ for (int row = 0; row < original_im.nrows(); ++row)
+ for (int col = 0; col < original_im.ncols(); ++col)
+ {
+ this->in[row * original_im.ncols() + col].re =
+ original_im(row, col).real();
+ this->in[row * original_im.ncols() + col].im =
+ original_im(row, col).imag();
+ }
+
+ this->p = fftw2d_create_plan(original_im.nrows(), original_im.ncols(),
+ FFTW_FORWARD, FFTW_ESTIMATE);
+ this->p_inv = fftw2d_create_plan(original_im.nrows(), original_im.ncols(),
+ FFTW_BACKWARD, FFTW_ESTIMATE);
+
+ this->trans_im = image2d<ntg::cplx<ntg::rect, ntg::float_d> >(original_im.size());
+ }
+
+ /*!
+ ** \brief Compute and return the transform.
+ */
+ image2d<ntg::cplx<R, ntg::float_d> > transform()
+ {
+ fftwnd_one(this->p, this->in, this->out);
+
+ unsigned denom = this->trans_im.nrows() * this->trans_im.ncols();
+ int i = 0;
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = 0; col < this->trans_im.ncols(); ++col)
+ {
+ this->out[i].re /= denom;
+ this->out[i].im /= denom;
+ this->trans_im(row, col) = ntg::cplx<ntg::rect, ntg::float_d>(this->out[i].re,
+ this->out[i].im);
+ ++i;
+ }
+ return this->trans_im;
+ }
+
+ /*!
+ ** \brief Compute and return the invert transform.
+ **
+ ** \param T1 Data type of output image.
+ */
+ template <class T1>
+ image2d<ntg::cplx<R, T1> > transform_inv()
+ {
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = 0; col < this->trans_im.ncols(); ++col)
+ {
+ this->out[row * this->trans_im.ncols() + col].re = this->trans_im(row, col).real();
+ this->out[row * this->trans_im.ncols() + col].im = this->trans_im(row, col).imag();
+ }
+ fftwnd_one(this->p_inv, this->out, this->in);
+
+ image2d<ntg::cplx<R, T1> > new_im(this->trans_im.size());
+ int i = 0;
+ for (int row = 0; row < this->trans_im.nrows(); ++row)
+ for (int col = 0; col < this->trans_im.ncols(); ++col)
+ {
+ new_im(row, col) = this->in[i];
+ ++i;
+ }
+ return new_im;
+ }
+
+ /*!
+ ** \brief Compute and return the invert transform.
+ */
+ image2d<ntg::cplx<R, T> > transform_inv()
+ {
+ return transform_inv<T>();
+ }
+
+ };
+
+ } // end of namespace transforms
+
+} // end of namespace oln
+
+# endif // HAVE_FFTW
+
+#endif // ! MLN_TRANSFORM_FFT_HH
Index: abraham/mln/value/shell.hh
--- abraham/mln/value/shell.hh (revision 2815)
+++ abraham/mln/value/shell.hh (working copy)
@@ -49,7 +49,7 @@
namespace impl
{
template <typename F, typename I, class C>
- struct shell_;
+ struct shell_ { };
template <typename F, typename I>
struct shell_<F, I, Function_v2w2v<void> >
Index: nature/histo_hsi.cc
--- nature/histo_hsi.cc (revision 2815)
+++ nature/histo_hsi.cc (working copy)
@@ -39,6 +39,7 @@
#include <mln/value/hsi.hh>
#include <mln/fun/v2v/rgb_to_hsi.hh>
+#include <mln/level/to_enc.hh>
#include <mln/fun/meta/hue.hh>
#include <mln/fun/meta/sat.hh>
#include <mln/fun/meta/inty.hh>
@@ -68,21 +69,25 @@
histo::data<float01_8> h = histo::compute(ima);
// Compute histo max
- size_t max = 0;
+ unsigned max = 0;
mln_viter(mln::value::set<float01_8>) v(h.vset());
for_all(v)
if (h(v) > max)
max = h(v);
+ std::cout << std::endl;
+
image2d<bool> output(max, mln_card(float01_8), 0);
+ std::cout << max << "x" << mln_card(float01_8) << std::endl;
level::fill(output, true);
for_all(v)
for (size_t i = 0; i < h(v); ++i)
{
- // std::cout << height - i << ", " << (u_t)v << std::endl;
- output(point2d(max - i - 1, (float01_8)v)) = false;
+ // std::cout << max - i - 1 << ", " << (unsigned) (((float01_8)v).to_enc()) << " ; " ;
+ if (output.has(point2d(max - i - 1, ((float01_8)v).to_enc() )))
+ output(point2d(max - i - 1, ((float01_8)v).to_enc() )) = false;
}
io::pbm::save(output, name);
@@ -107,7 +112,9 @@
std::string n(argv[i]);
n.erase(n.length() - 4);
- // io::pgm::save(hue, n.append("_hue.pgm"));
+ image2d<int_u8> henc;
+ level::transform(hue, fun::v2v::enc< float01_8 >(), henc);
+ io::pgm::save(henc, n.append("_hue.pgm"));
image2d<hsi_f>::piter p(hsi.domain());
float m = 0;
@@ -125,13 +132,14 @@
save_histo(hue, name.append("_hue.pbm"));
- /*
thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > s(hsi);
- cast_image_<u_t, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > sat(s);
+ cast_image_<float01_8, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > sat(s);
n = argv[i];
n.erase(n.length() - 4);
- io::pgm::save(sat, n.append("_sat.pgm"));
+ image2d<int_u8> senc;
+ level::transform(sat, fun::v2v::enc< float01_8 >(), senc);
+ io::pgm::save(senc, n.append("_sat.pgm"));
m = 0;
for_all(p)
@@ -144,14 +152,16 @@
name = argv[i];
name.erase(name.length() - 4);
- save_histo(sat, name.append("_sat.pbm"), 100, 2560, npoints);
+ save_histo(sat, name.append("_sat.pbm"));
thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > l(hsi);
- cast_image_<u_t, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > inty(l);
+ cast_image_<float01_8, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > inty(l);
n = argv[i];
n.erase(n.length() - 4);
- io::pgm::save(inty, n.append("_inty.pgm"));
+ image2d<int_u8> ienc;
+ level::transform(inty, fun::v2v::enc< float01_8 >(), ienc);
+ io::pgm::save(ienc, n.append("_inty.pgm"));
m = 0;
@@ -165,7 +175,7 @@
name = argv[i];
name.erase(name.length() - 4);
- save_histo(inty, name.append("_inty.pbm"), 256, 256, npoints);
- */
+ save_histo(inty, name.append("_inty.pbm"));
+
}
}
Index: nature/hom.cc
--- nature/hom.cc (revision 2815)
+++ nature/hom.cc (working copy)
@@ -42,8 +42,11 @@
#include <mln/binarization/threshold.hh>
#include <mln/estim/mean.hh>
#include <mln/morpho/hit_or_miss.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/morpho/opening.hh>
-
+#include <mln/win/hline2d.hh>
+#include <mln/win/vline2d.hh>
int main(int argc, const char * argv[])
{
@@ -59,15 +62,18 @@
{
typedef int_u8 int_t;
+ border::thickness = 21;
+
image2d<int_t> ima;
io::pgm::load(ima, argv[i]);
// Compute the mean
int_t mean = estim::mean(ima);
- image2d<bool> imab = binarization::threshold(ima, mean);
- border::thickness = 10;
+ image2d<bool> imab = binarization::threshold(ima, 10);
+
+
window2d winout;
window2d winin;
@@ -80,15 +86,15 @@
// 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0};
-// static const bool matout [] = {0, 0, 0, 0, 0,
-// 0, 1, 0, 0, 0,
-// 0, 1, 0, 0, 0,
-// 0, 1, 1, 1, 0,
-// 0, 0, 0, 0, 0};
-
- static const bool blmatout [] = {0, 0, 0,
- 1, 0, 0,
- 1, 1, 0};
+ static const bool blmatout [] = {0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0};
+
+// static const bool blmatout [] = {0, 0, 0,
+// 1, 0, 0,
+// 1, 1, 0};
convert::from_to(blmatout, winout);
@@ -101,58 +107,170 @@
// 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0};
-// static const bool matin [] = {0, 0, 1, 0, 0,
-// 0, 0, 1, 0, 0,
-// 0, 0, 1, 1, 1,
-// 0, 0, 0, 0, 0,
-// 0, 0, 0, 0, 0};
-
- static const bool blmatin [] = {0, 1, 0,
- 0, 1, 1,
- 0, 0, 0};
+ static const bool blmatin [] = {0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+// static const bool blmatin [] = {0, 1, 0,
+// 0, 1, 1,
+// 0, 0, 0};
convert::from_to(blmatin, winin);
image2d<bool> bottom_left = morpho::hit_or_miss(imab, winout, winin);
- static const bool brmatout [] = {0, 0, 0,
- 0, 0, 1,
- 0, 1, 1};
-
- static const bool brmatin [] = {0, 1, 0,
- 1, 1, 0,
- 0, 0, 0};
+// static const bool brmatout [] = {0, 0, 0,
+// 0, 0, 1,
+// 0, 1, 1};
+
+// static const bool brmatin [] = {0, 1, 0,
+// 1, 1, 0,
+// 0, 0, 0};
+
+ static const bool brmatout [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool brmatin [] = {0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
convert::from_to(brmatout, winout);
convert::from_to(brmatin, winin);
image2d<bool> bottom_right = morpho::hit_or_miss(imab, winout, winin);
- static const bool urmatout [] = {0, 1, 1,
- 0, 0, 1,
- 0, 0, 0};
-
- static const bool urmatin [] = {0, 0, 0,
- 1, 1, 0,
- 0, 1, 0};
+// static const bool urmatout [] = {0, 1, 1,
+// 0, 0, 1,
+// 0, 0, 0};
+
+// static const bool urmatin [] = {0, 0, 0,
+// 1, 1, 0,
+// 0, 1, 0};
+
+ static const bool urmatout [] = {0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool urmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0};
+
convert::from_to(urmatout, winout);
convert::from_to(urmatin, winin);
image2d<bool> up_right = morpho::hit_or_miss(imab, winout, winin);
- static const bool ulmatout [] = {1, 1, 0,
- 1, 0, 0,
- 0, 0, 0};
-
- static const bool ulmatin [] = {0, 0, 0,
- 0, 1, 1,
- 0, 1, 0};
+// static const bool ulmatout [] = {1, 1, 0,
+// 1, 0, 0,
+// 0, 0, 0};
+
+// static const bool ulmatin [] = {0, 0, 0,
+// 0, 1, 1,
+// 0, 1, 0};
+
+ static const bool ulmatout [] = {0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool ulmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0};
+
convert::from_to(ulmatout, winout);
convert::from_to(ulmatin, winin);
image2d<bool> up_left = morpho::hit_or_miss(imab, winout, winin);
+ static const bool umatout [] = {0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool umatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(umatout, winout);
+ convert::from_to(umatin, winin);
+ image2d<bool> up = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool bmatout [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0};
+
+ static const bool bmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(bmatout, winout);
+ convert::from_to(bmatin, winin);
+ image2d<bool> bottom = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool lmatout [] = {0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0};
+
+ static const bool lmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(lmatout, winout);
+ convert::from_to(lmatin, winin);
+ image2d<bool> left = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool rmatout [] = {0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0};
+
+ static const bool rmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(rmatout, winout);
+ convert::from_to(rmatin, winin);
+ image2d<bool> right = morpho::hit_or_miss(imab, winout, winin);
+
+
+
std::string name(argv[i]);
name.erase(name.length() - 4);
@@ -160,7 +278,37 @@
name = argv[i];
name.erase(name.length() - 4);
- io::pbm::save( up_left + up_right + bottom_right + bottom_left,
+ // image2d<bool> final(right.domain());
+ // level::fill(final, false);
+ // mln_piter_(image2d<bool>) p(final.domain());
+ // for_all(p)
+ // final(p) = up_left(p) || up_right(p) || bottom_right(p) || bottom_left(p) || up(p) || bottom(p) || left(p) || right(p);
+
+ image2d<bool> inter (up_left + up_right + bottom_right + bottom_left + up + bottom + left + right);
+
+ static const bool vert [] = {0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0};
+
+ static const bool hori [] = {0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0};
+
+ convert::from_to(vert, winin);
+ convert::from_to(hori, winout);
+
+ image2d<bool> final = morpho::opening(inter, win::hline2d(20));
+ final += morpho::opening(inter, win::vline2d(20));
+
+ io::pbm::save( final,
name.append("_hom.pbm"));
}
}
Index: nature/mco.cc
--- nature/mco.cc (revision 2815)
+++ nature/mco.cc (working copy)
@@ -34,10 +34,14 @@
// Normalization
unsigned m, M;
estim::min_max(co, m, M);
+ std::cout << "max : " << M << std::endl;
double norm = 255./M;
mln_piter_ (image2d<unsigned>) p (co.domain());
for_all(p)
+ {
+ // std::cout << co(p) << " ; ";
co(p) *= norm;
+ }
io::pgm::save(cast_image<int_u<8> >(co), name.append("_mco.pgm"));
}
Index: nature/nature.cc
--- nature/nature.cc (revision 0)
+++ nature/nature.cc (revision 0)
@@ -0,0 +1,408 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/thru.hh>
+
+#include <mln/io/ppm/load.hh>
+
+#include <mln/histo/compute.hh>
+
+#include <mln/level/transform.hh>
+#include <mln/level/paste.hh>
+#include <mln/level/to_enc.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/hsi.hh>
+
+#include <mln/fun/v2v/rgb_to_hsi.hh>
+#include <mln/fun/meta/hue.hh>
+#include <mln/fun/meta/sat.hh>
+#include <mln/fun/meta/inty.hh>
+
+#include <mln/win/hline2d.hh>
+#include <mln/win/vline2d.hh>
+
+#include <mln/morpho/hit_or_miss.hh>
+#include <mln/morpho/gradient.hh>
+#include <mln/morpho/opening.hh>
+
+#include <mln/binarization/threshold.hh>
+
+#include <mln/estim/mean.hh>
+
+#include "co_occurence.hh"
+
+using namespace mln;
+using namespace value;
+
+enum doctype
+ {
+ TEXT,
+ SCREENSHOT,
+ PHOTO,
+ DRAWING,
+ NB_DOCTYPE
+ };
+
+template <typename T>
+unsigned nb_peaks (histo::data<T> &h)
+{
+ // First, we compute the maximum, ignoring the first column because it
+ // contains nonsense points
+
+ unsigned max = 0;
+ mln_viter(mln::value::set<T>) v(h.vset());
+
+ for_all(v)
+ if (((T)v).to_enc() && (h(v) > max))
+ max = h(v);
+
+ // We take the first value into account
+ if (h[0] / 6 > max)
+ max = h[0] / 6;
+
+ // Now we count the number of peaks over max / 4
+ unsigned cpt = 0;
+ for_all(v)
+ if (h(v) >= max / 4)
+ cpt ++;
+
+ return cpt;
+}
+
+
+int main (int argc, const char * argv [])
+{
+ if (argc != 2) {
+ std::cerr << "usage: " << argv[0] << " in.pgm" << std::endl;
+ return 1;
+ }
+
+ unsigned score[NB_DOCTYPE];
+ for (unsigned i = 0; i < NB_DOCTYPE; ++i)
+ score[i] = 0;
+
+ border::thickness = 21;
+
+ image2d<rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ // First, we get the HSI histograms and corresponding greyscale versions of the picture
+
+ image2d<hsi_f> hsi = level::transform(input, fun::v2v::f_rgb_to_hsi_f);
+
+ thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > hue(hsi);
+ thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > sat(hsi);
+ thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > inty(hsi);
+
+ cast_image_<float01_8, thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > > qhue(hue); // quantified hue
+ cast_image_<float01_8, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > qsat(sat); // quantified sat
+ cast_image_<float01_8, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > qinty(inty); // quantified inty
+
+ histo::data<float01_8> hhue = histo::compute(qhue);
+ histo::data<float01_8> hsat = histo::compute(qsat);
+ histo::data<float01_8> hinty = histo::compute(qinty);
+
+
+ // Compute the number of peaks in the histogram to give a first intuition
+
+ unsigned n = nb_peaks(hhue) * 3;
+
+ if (n > 100)
+ n = 100;
+
+ score[PHOTO] += n;
+ score[SCREENSHOT] += 20 + 80 - n * 80 / 100;
+ score[TEXT] += 100 - n;
+ score[DRAWING] += 20 + 80 - n * 80 / 100;
+
+ std::cout << "Test 1 : peaks number[" << nb_peaks(hhue) << "]" << std::endl
+ << "Photo : " << score[PHOTO] << std::endl
+ << "Screenshot : " << score[SCREENSHOT] << std::endl
+ << "Text : " << score[TEXT] << std::endl
+ << "Drawing : " << score[DRAWING] << std::endl << std::endl;
+
+
+ // Now we compute the co-occurence matrice
+
+ dpoint2d d(0, 1);
+ image2d<int_u8> uinty (qinty.domain());
+ {
+ image2d<unsigned char> tmp = level::transform(qinty, fun::v2v::enc< float01_8 >());
+ level::paste(tmp, uinty);
+ /* mln_piter_(image2d<unsigned char>) p(tmp.domain());
+ for_all(p)
+ uinty(p) = tmp(p);
+ */
+ }
+
+ image2d<unsigned> mco (co_occurence(uinty, d));
+
+ // If there is a plain background, there will be a massive peak in the diagonal of the matrix
+ unsigned max = 0;
+ for (unsigned i = 0; i < mco.nrows(); i++)
+ if (mco.at(i, i) > max)
+ max = mco.at(i, i);
+
+ for (unsigned i = 0; i < mco.nrows() - 1; i++) {
+ if (mco.at(i + 1, i) > max)
+ max = mco.at(i + 1, i);
+ if (mco.at(i, i + 1) > max)
+ max = mco.at(i, i + 1);
+ }
+
+ max = max * 100 / input.nelements();
+
+ score[PHOTO] += 100 - max;
+ score[TEXT] += max * 2;
+
+ score[SCREENSHOT] += 50 + max / 2;
+ score[DRAWING] += 50 + max / 2;
+
+ std::cout << "Test 2 : co-occurence matrix diag_max[" << max << "]" << std::endl
+ << "Photo : +" << 100 - max << std::endl;
+
+ std::cout << "Screenshot : +" << 50 + max / 2 << std::endl;
+
+ std::cout << "Text : +" << max * 2 << std::endl;
+
+ std::cout << "Drawing : +" << 50 + max / 2 << std::endl << std::endl;
+
+
+
+
+ // A good way to detect screenshots : rectangle detection
+
+ // First, we compute the gradient
+
+ win::rectangle2d rect(5, 5);
+ image2d<int_u8> grad = morpho::gradient(uinty, rect);
+
+ // Then, we apply a lot of hit or miss filters !
+
+ // Compute the mean
+ int_u8 mean = estim::mean(grad);
+
+ image2d<bool> imab = binarization::threshold(grad, 10);
+
+ window2d winout;
+ window2d winin;
+
+ static const bool blmatout [] = {0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0};
+
+ convert::from_to(blmatout, winout);
+
+ static const bool blmatin [] = {0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+ convert::from_to(blmatin, winin);
+
+ image2d<bool> bottom_left = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool brmatout [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool brmatin [] = {0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(brmatout, winout);
+ convert::from_to(brmatin, winin);
+ image2d<bool> bottom_right = morpho::hit_or_miss(imab, winout, winin);
+
+ static const bool urmatout [] = {0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool urmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0};
+
+
+ convert::from_to(urmatout, winout);
+ convert::from_to(urmatin, winin);
+ image2d<bool> up_right = morpho::hit_or_miss(imab, winout, winin);
+
+ static const bool ulmatout [] = {0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool ulmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0};
+
+
+ convert::from_to(ulmatout, winout);
+ convert::from_to(ulmatin, winin);
+ image2d<bool> up_left = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool umatout [] = {0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+ static const bool umatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(umatout, winout);
+ convert::from_to(umatin, winin);
+ image2d<bool> up = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool bmatout [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0};
+
+ static const bool bmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(bmatout, winout);
+ convert::from_to(bmatin, winin);
+ image2d<bool> bottom = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool lmatout [] = {0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0};
+
+ static const bool lmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(lmatout, winout);
+ convert::from_to(lmatin, winin);
+ image2d<bool> left = morpho::hit_or_miss(imab, winout, winin);
+
+
+ static const bool rmatout [] = {0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0,
+ 0, 0, 0, 1, 0};
+
+ static const bool rmatin [] = {0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0};
+
+
+ convert::from_to(rmatout, winout);
+ convert::from_to(rmatin, winin);
+ image2d<bool> right = morpho::hit_or_miss(imab, winout, winin);
+
+ image2d<bool> inter (up_left + up_right + bottom_right + bottom_left + up + bottom + left + right);
+
+ image2d<bool> final = morpho::opening(inter, win::hline2d(20));
+ final += morpho::opening(inter, win::vline2d(20));
+
+ // Now we count blank points in our result
+
+ unsigned cpt = 0;
+ mln_piter_(image2d<bool>) p (final.domain());
+ for_all(p)
+ cpt += final(p);
+
+ // compute the percentage of blank points
+
+ cpt = 1000 * cpt / final.domain().nsites();
+
+ if (cpt > 50)
+ cpt = 50;
+
+ score[PHOTO] += 50 - cpt;
+ score[SCREENSHOT] += cpt * 5;
+ score[TEXT] += 50 + cpt * max / 10;
+ score[DRAWING] += 2 * (50 - cpt);
+
+ std::cout << "Test 3 : rectangle detection[" << cpt << "]" << std::endl
+ << "Photo : +" << 50 - cpt << std::endl
+ << "Screenshot : +" << cpt * 5 << std::endl
+ << "Text : +" << 50 + cpt * max / 10 << std::endl
+ << "Drawing : +" << 2 * (50 - cpt) << std::endl << std::endl;
+
+
+ // Print the result !
+
+ std::cout << "Photo : " << score[PHOTO] << std::endl
+ << "Screenshot : " << score[SCREENSHOT] << std::endl
+ << "Text : " << score[TEXT] << std::endl
+ << "Drawing : " << score[DRAWING] << std::endl;
+
+ max = 0;
+ unsigned index = 0;
+
+ for (unsigned i = 0; i < NB_DOCTYPE; ++i)
+ if (score[i] > max)
+ {
+ max = score[i];
+ index = i;
+ }
+
+ return index;
+}
Index: nature/opening.cc
--- nature/opening.cc (revision 2815)
+++ nature/opening.cc (working copy)
@@ -49,7 +49,7 @@
image2d<int_u8> ima;
io::pgm::load(ima, argv[i]);
- win::rectangle2d rect(5, 5);
+ win::rectangle2d rect(1, 1);
border::thickness = 11;
std::string name(argv[i]);
Index: nature/test.sh
--- nature/test.sh (revision 0)
+++ nature/test.sh (revision 0)
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+for i in $@;
+do
+ echo $i;
+ echo "";
+ ./nature $i;
+ echo "";
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
+ echo "";
+done;
Property changes on: nature/test.sh
___________________________________________________________________
Added: svn:executable
+ *
1
0
Re: [Olena-patches] [Olena] #43: Fix the initialization of all global constants.
by Olena 05 Nov '08
by Olena 05 Nov '08
05 Nov '08
#43: Fix the initialization of all global constants.
------------------------+---------------------------------------------------
Reporter: garrigues | Owner: Olena Team
Type: defect | Status: new
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Resolution: | Keywords:
------------------------+---------------------------------------------------
Comment (by lazzara):
Fixed in mln/value/*.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/43#comment:1>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
* mln/binarization/binarization.hh,
* mln/level/abs.hh,
* mln/level/saturate.hh,
* mln/level/to_enc.hh,
* tests/io/pgm/pgm16.cc,
* tests/io/pgm/pgm19.cc,
* tests/io/pgm/pgm27.cc,
* tests/value/float01.cc: Update here.
* mln/level/transform.hh: Remove useless prototype.
---
milena/ChangeLog | 15 +++++++++++++++
milena/mln/binarization/binarization.hh | 2 +-
milena/mln/level/abs.hh | 4 ++--
milena/mln/level/saturate.hh | 6 +++---
milena/mln/level/to_enc.hh | 4 ++--
milena/mln/level/transform.hh | 10 +---------
milena/tests/io/pgm/pgm16.cc | 4 ++--
milena/tests/io/pgm/pgm19.cc | 4 ++--
milena/tests/io/pgm/pgm27.cc | 4 ++--
milena/tests/value/float01.cc | 6 +++---
10 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 63ba0ed..c013c05 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,18 @@
+2008-11-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update use of level::transform().
+
+ * mln/binarization/binarization.hh,
+ * mln/level/abs.hh,
+ * mln/level/saturate.hh,
+ * mln/level/to_enc.hh,
+ * tests/io/pgm/pgm16.cc,
+ * tests/io/pgm/pgm19.cc,
+ * tests/io/pgm/pgm27.cc,
+ * tests/value/float01.cc: Update here.
+
+ * mln/level/transform.hh: Remove useless prototype.
+
2008-11-05 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make 2 x 1D convolution work again.
diff --git a/milena/mln/binarization/binarization.hh b/milena/mln/binarization/binarization.hh
index cd1296d..0c8d2bd 100644
--- a/milena/mln/binarization/binarization.hh
+++ b/milena/mln/binarization/binarization.hh
@@ -70,7 +70,7 @@ namespace mln
trace::entering("binarization::impl::binarization_");
mln_concrete_ch_value(I, bool) output(input.domain());
- level::transform(input, fun, output);
+ output = level::transform(input, fun);
trace::exiting("binarization::impl::binarization_");
return output;
diff --git a/milena/mln/level/abs.hh b/milena/mln/level/abs.hh
index a74b144..9a544d7 100644
--- a/milena/mln/level/abs.hh
+++ b/milena/mln/level/abs.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -72,7 +72,7 @@ namespace mln
trace::entering("level::abs");
mln_precondition(exact(input).domain() == exact(output).domain());
- level::transform(input, fun::v2v::abs<mln_value(I)>(), output);
+ output = level::transform(input, fun::v2v::abs<mln_value(I)>());
trace::exiting("level::abs");
}
diff --git a/milena/mln/level/saturate.hh b/milena/mln/level/saturate.hh
index 8b9c4f3..d3a04e7 100644
--- a/milena/mln/level/saturate.hh
+++ b/milena/mln/level/saturate.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -102,7 +102,7 @@ namespace mln
mln_precondition(exact(input).domain() == exact(output).domain());
fun::v2v::saturate<mln_value(O)> f;
- level::transform(input, f, output);
+ output = level::transform(input, f);
trace::exiting("level::saturate");
}
@@ -118,7 +118,7 @@ namespace mln
mln_precondition(exact(input).domain() == exact(output).domain());
fun::v2v::saturate<mln_value(O)> f(min, max);
- level::transform(input, f, output);
+ output = level::transform(input, f);
trace::exiting("level::saturate");
}
diff --git a/milena/mln/level/to_enc.hh b/milena/mln/level/to_enc.hh
index 19661bb..96e834b 100644
--- a/milena/mln/level/to_enc.hh
+++ b/milena/mln/level/to_enc.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -64,7 +64,7 @@ namespace mln
trace::entering("level::to_enc");
mln_precondition(exact(output).domain() == exact(input).domain());
- level::transform(input, fun::v2v::enc< mln_value(I) >(), output);
+ output = level::transform(input, fun::v2v::enc< mln_value(I) >());
trace::exiting("level::to_enc");
}
diff --git a/milena/mln/level/transform.hh b/milena/mln/level/transform.hh
index 1b21772..adc6467 100644
--- a/milena/mln/level/transform.hh
+++ b/milena/mln/level/transform.hh
@@ -53,23 +53,15 @@ namespace mln
namespace level
{
- /*! Transform the image \p input through a function \p f to set
- * the \p output image.
+ /*! Transform the image \p input through a function \p f
*
* \param[in] input The input image.
* \param[in] f The function.
- * \param[out] output The result image.
*
* This routine runs: \n
* for all p of \p input, \p output(p) = \p f( \p input(p) ).
*
- * \pre \p output.domain >= \p input.domain
*/
- template <typename I, typename F, typename O>
- void transform(const Image<I>& input, const Function_v2v<F>& f,
- Image<O>& output);
-
-
template <typename I, typename F>
mln_ch_value(I, mln_result(F))
transform(const Image<I>& input, const Function_v2v<F>& f);
diff --git a/milena/tests/io/pgm/pgm16.cc b/milena/tests/io/pgm/pgm16.cc
index baff76c..29c19f1 100644
--- a/milena/tests/io/pgm/pgm16.cc
+++ b/milena/tests/io/pgm/pgm16.cc
@@ -82,13 +82,13 @@ int main()
image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
image2d<int_u16> out(lena.domain());
- level::transform(lena, to16bits(), out);
+ out = level::transform(lena, to16bits());
io::pgm::save(out, "out16.pgm");
image2d<int_u16> lena2 = io::pgm::load<int_u16>("out16.pgm");
image2d<int_u8> out2(lena.domain());
- level::transform(lena2, to8bits(), out2);
+ out2 = level::transform(lena2, to8bits());
io::pgm::save(out2, "out8.pgm");
}
diff --git a/milena/tests/io/pgm/pgm19.cc b/milena/tests/io/pgm/pgm19.cc
index 3fa8490..91b863a 100644
--- a/milena/tests/io/pgm/pgm19.cc
+++ b/milena/tests/io/pgm/pgm19.cc
@@ -80,13 +80,13 @@ int main()
image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
image2d<int_u19> out(lena.domain());
- level::transform(lena, to19bits(), out);
+ out = level::transform(lena, to19bits());
io::pgm::save(out, "out19.pgm");
image2d<int_u19> lena2 = io::pgm::load<int_u19>("out19.pgm");
image2d<int_u8> out2(lena.domain());
- level::transform(lena2, to8bits(), out2);
+ out2 = level::transform(lena2, to8bits());
io::pgm::save(out2, "out8.pgm");
assert(out2 == lena);
}
diff --git a/milena/tests/io/pgm/pgm27.cc b/milena/tests/io/pgm/pgm27.cc
index 6945b94..244b2e6 100644
--- a/milena/tests/io/pgm/pgm27.cc
+++ b/milena/tests/io/pgm/pgm27.cc
@@ -79,14 +79,14 @@ int main()
image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
image2d<int_u27> out(lena.domain());
- level::transform(lena, to27bits(), out);
+ out = level::transform(lena, to27bits());
io::pgm::save(out, "out27.pgm");
image2d<int_u27> lena2;
io::pgm::load(lena2, "out27.pgm");
image2d<int_u8> out2(lena.domain());
- level::transform(lena2, to8bits(), out2);
+ out2 = level::transform(lena2, to8bits());
io::pgm::save(out2, "out8.pgm");
assert(out2 == lena);
diff --git a/milena/tests/value/float01.cc b/milena/tests/value/float01.cc
index 47b8c48..9dbd6d2 100644
--- a/milena/tests/value/float01.cc
+++ b/milena/tests/value/float01.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -133,13 +133,13 @@ int main()
image2d<float01_16> out(lena.domain());
image2d<float01_16> tmp(lena.domain());
- level::transform(lena, tofloat01(), tmp);
+ tmp = level::transform(lena, tofloat01());
level::median(tmp, rect, out);
level::median(lena, rect, ref);
- level::transform(out, to8bits(), lena);
+ lena = level::transform(out, to8bits());
io::pgm::save(lena, "out.pgm");
io::pgm::save(ref, "ref.pgm");
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make 2 x 1D convolution work again.
* mln/linear/line_x2_convolve.hh: Rename as...
* mln/linear/convolve_2x1d.hh: ...this.
Revamp.
* tests/linear/convolve_2x1d.cc: New.
* tests/linear/Makefile.am: Update.
* mln/linear/convolve_directional.hh: .
* mln/border/resize.hh (todo): Remove; we use level::fill.
(include): Fix missing level/fill.
(resize_): Remove useless code.
* mln/border/duplicate.hh: Update doc style.
* mln/border/adjust.hh: Likewise.
(adjust): Remove useless code; add postcondition.
* mln/extension/adjust.hh: New.
* mln/extension/duplicate.hh: New.
* mln/extension/adjust_duplicate.hh: Update.
* mln/extension/adjust_fill.hh: Update.
* mln/extension/all.hh: Update.
* mln/util/ord.hh: Add doc.
* mln/util/max.hh: New.
mln/border/adjust.hh | 22 ++----
mln/border/duplicate.hh | 7 -
mln/border/resize.hh | 20 +----
mln/extension/adjust.hh | 130 +++++++++++++------------------------
mln/extension/adjust_duplicate.hh | 70 +++++--------------
mln/extension/adjust_fill.hh | 72 +++++---------------
mln/extension/all.hh | 16 ++--
mln/extension/duplicate.hh | 74 +++++++++++++++++++++
mln/linear/convolve_2x1d.hh | 69 ++++++++++---------
mln/linear/convolve_directional.hh | 3
mln/util/max.hh | 67 +++++++++++++++++++
mln/util/ord.hh | 15 ++--
tests/linear/Makefile.am | 2
tests/linear/convolve_2x1d.cc | 19 +++--
14 files changed, 315 insertions(+), 271 deletions(-)
Index: tests/linear/Makefile.am
--- tests/linear/Makefile.am (revision 2813)
+++ tests/linear/Makefile.am (working copy)
@@ -7,6 +7,7 @@
check_PROGRAMS = \
convolve \
convolve_directional \
+ convolve_2x1d \
gaussian \
lap \
log \
@@ -16,6 +17,7 @@
gaussian_SOURCES = gaussian.cc
lap_SOURCES = lap.cc
convolve_directional_SOURCES = convolve_directional.cc
+convolve_2x1d_SOURCES = convolve_2x1d.cc
log_SOURCES = log.cc
sobel_SOURCES = sobel.cc
Index: tests/linear/convolve_2x1d.cc
--- tests/linear/convolve_2x1d.cc (revision 2807)
+++ tests/linear/convolve_2x1d.cc (working copy)
@@ -26,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/linear/convolve_directional.cc
- *
- * \brief Tests on mln::linear::convolve_directional.
- */
+/// \file tests/linear/convolve_2x1d.cc
+///
+/// Tests on mln::linear::convolve_2x1d.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
@@ -41,7 +40,7 @@
#include <mln/core/alias/w_window2d_float.hh>
#include <mln/border/thickness.hh>
-#include <mln/linear/convolve_directional.hh>
+#include <mln/linear/convolve_2x1d.hh>
#include "tests/data.hh"
@@ -51,13 +50,17 @@
using namespace mln;
using value::int_u8;
- border::thickness = 4;
+ border::thickness = 5;
image2d<int_u8> lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- float ws[] = { .11, .11, .11, .11, .11, .11, .11, .11, .11 };
- image2d<float> tmp = linear::convolve_directional(lena, 1, ws);
+ float
+ w = 1.f / 11,
+ v = 1.f / 3;
+ float hws[] = { w, w, w, w, w, w, w, w, w, w, w };
+ float vws[] = { v, v, v };
+ image2d<float> tmp = linear::convolve_2x1d(lena, hws, vws);
io::pgm::save(level::transform(tmp, math::round<int_u8>()),
"out.pgm");
Index: mln/linear/convolve_directional.hh
--- mln/linear/convolve_directional.hh (revision 2813)
+++ mln/linear/convolve_directional.hh (working copy)
@@ -70,6 +70,9 @@
convolve_directional(const Image<I>& input, unsigned dir, W (&weights)[S])
{
trace::entering("linear::convolve_directional");
+
+ mlc_bool(S % 2 == 1)::check();
+
mln_precondition(exact(input).has_data());
typedef mln_site(I) P;
mln_precondition(dir < P::dim);
Index: mln/linear/convolve_2x1d.hh
--- mln/linear/convolve_2x1d.hh (revision 2807)
+++ mln/linear/convolve_2x1d.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,16 +26,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_LINEAR_LINE_X2_CONVOLVE_HH
-# define MLN_LINEAR_LINE_X2_CONVOLVE_HH
+#ifndef MLN_LINEAR_CONVOLVE_2X1D_HH
+# define MLN_LINEAR_CONVOLVE_2X1D_HH
-/*! \file mln/linear/line_x2_convolve.hh
- *
- * \brief 2D convolution by a couple of line kernels.
- */
-
-# include <mln/linear/line_convolve.hh>
-# include <mln/core/image/t_image.hh>
+/// \file mln/linear/convolve_2x1d.hh
+///
+/// 2D convolution by a couple of line kernels.
+
+# include <mln/linear/convolve_directional.hh>
+# include <mln/extension/adjust.hh>
+# include <mln/util/max.hh>
@@ -47,40 +48,44 @@
/*! Convolution of an image \p input by two weighted line-shapes
* windows.
*
- * \warning Computation of \p output(p) is performed with the
- * value type of \p output.
- *
* \warning The weighted window is used as-is, considering that
* its symmetrization is handled by the client.
*
- * \pre output.domain = input.domain
+ * \pre input.has_data
*/
template <typename I,
- typename W, unsigned Nr, unsigned Nc,
- typename O>
- void line_x2_convolve(const Image<I>& input,
- W (&row_weights)[Nr], W (&col_weights)[Nc],
- Image<O>& output);
+ typename W, unsigned Sh, unsigned Sv>
+ mln_ch_convolve(I, W)
+ convolve_2x1d(const Image<I>& input,
+ W (&horizontal_weights)[Sh],
+ W (& vertical_weights)[Sv]);
# ifndef MLN_INCLUDE_ONLY
template <typename I,
- typename W, unsigned Nr, unsigned Nc,
- typename O>
- inline
- void line_x2_convolve(const Image<I>& input,
- W (&row_weights)[Nr], W (&col_weights)[Nc],
- Image<O>& output)
+ typename W, unsigned Sh, unsigned Sv>
+ mln_ch_convolve(I, W)
+ convolve_2x1d(const Image<I>& input,
+ W (&horizontal_weights)[Sh],
+ W (& vertical_weights)[Sv])
{
- // FIXME: Check 2D.
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::convolve_2x1d");
+
+ mlc_bool(Sh % 2 == 1)::check();
+ mlc_bool(Sv % 2 == 1)::check();
+
+ mln_precondition(exact(input).has_data());
+
+ extension::adjust(input, util::max(Sh / 2, Sv / 2));
- O tmp(exact(output).domain());
- linear::line_convolve(input, row_weights, tmp);
+ mln_ch_convolve(I, W) tmp, output;
+ // Horizontal kernel so columns (index 1) are varying.
+ tmp = linear::convolve_directional(input, 1, horizontal_weights);
+ output = linear::convolve_directional( tmp, 0, vertical_weights);
- t_image<O> swap_output = swap_coords(output, 0, 1);
- linear::line_convolve(swap_coords(tmp, 0, 1), col_weights, swap_output);
+ trace::exiting("linear::convolve_2x1d");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -90,4 +95,4 @@
} // end of namespace mln
-#endif // ! MLN_LINEAR_LINE_X2_CONVOLVE_HH
+#endif // ! MLN_LINEAR_CONVOLVE_2X1D_HH
Property changes on: mln/linear/convolve_2x1d.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2813)
+++ mln/border/resize.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,8 +34,6 @@
* \brief Define a function that resizes the virtual border of an
* image.
*
- * \todo Use level::fill!!!
- *
* \todo Test with a primary image with no notion of border; I guess
* it does not work.
*/
@@ -42,8 +41,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/routine/clone.hh>
# include <mln/border/get.hh>
-// # include <mln/level/fill.hh>
-// # include <mln/level/paste.hh>
+# include <mln/level/fill.hh>
namespace mln
@@ -110,26 +108,16 @@
template <typename I>
inline
void resize_(trait::image::ext_domain::none,
- const I& ima, unsigned thickness)
+ const I&, unsigned)
{
- // Avoid a warning about an undefined variable when NDEBUG
- // is not defined.
- (void) ima;
- (void) thickness;
-
// No-op.
}
template <typename I>
inline
void resize_(trait::image::ext_domain::fixed,
- const I& ima, unsigned thickness)
+ const I&, unsigned)
{
- // Avoid a warning about an undefined variable when NDEBUG
- // is not defined.
- (void) ima;
- (void) thickness;
-
// No-op.
}
Index: mln/border/duplicate.hh
--- mln/border/duplicate.hh (revision 2813)
+++ mln/border/duplicate.hh (working copy)
@@ -29,10 +29,9 @@
#ifndef MLN_BORDER_DUPLICATE_HH
# define MLN_BORDER_DUPLICATE_HH
-/*! \file mln/border/duplicate.hh
- *
- * \brief Define function that fills border using nearest pixels.
- */
+/// \file mln/border/duplicate.hh
+///
+/// Define function that fills border using nearest pixels.
# include <mln/core/concept/image.hh>
# include <mln/core/routine/primary.hh>
Index: mln/border/adjust.hh
--- mln/border/adjust.hh (revision 2813)
+++ mln/border/adjust.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,14 +29,13 @@
#ifndef MLN_BORDER_ADJUST_HH
# define MLN_BORDER_ADJUST_HH
-/*! \file mln/border/adjust.hh
- *
- * \brief Define a function that adjusts the thickness of an image
- * virtual border.
- */
+/// \file mln/border/adjust.hh
+///
+/// Define a function that adjusts the thickness of an image
+/// virtual border.
# include <mln/border/resize.hh>
-# include <mln/metal/is.hh>
+
namespace mln
{
@@ -62,18 +62,16 @@
template <typename I>
inline
- void adjust(const Image<I>& ima_, unsigned min_thickness)
+ void adjust(const Image<I>& ima, unsigned min_thickness)
{
trace::entering("border::adjust");
- if (min_thickness != 0)
- {
- const I& ima = exact(ima_);
- mln_precondition(ima.has_data());
+ mln_precondition(exact(ima).has_data());
if (border::get(ima) < min_thickness)
border::resize(ima, min_thickness);
- }
+
+ mln_postcondition(border::get(ima) >= min_thickness);
trace::exiting("border::adjust");
}
Index: mln/extension/adjust_duplicate.hh
--- mln/extension/adjust_duplicate.hh (revision 2813)
+++ mln/extension/adjust_duplicate.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,17 +28,15 @@
#ifndef MLN_CORE_EXTENSION_ADJUST_DUPLICATE_HH
# define MLN_CORE_EXTENSION_ADJUST_DUPLICATE_HH
-/*! \file mln/extension/adjust_duplicate.hh
- *
- * \brief Adjust the size of the domain extension then duplicate the
- * image inner boundary.
- *
- * \todo Fix doc.
- */
-
-# include <mln/border/adjust.hh>
-# include <mln/border/duplicate.hh>
-# include <mln/geom/delta.hh>
+/// \file mln/extension/adjust_duplicate.hh
+///
+/// Adjust the size of the domain extension then duplicate the image
+/// inner boundary.
+///
+/// \todo Fix doc.
+
+# include <mln/extension/adjust.hh>
+# include <mln/extension/duplicate.hh>
namespace mln
@@ -47,13 +45,7 @@
namespace extension
{
- /*! Fill the domain extension of image \p ima by duplicating the
- * image inner boundary.
- *
- * \param[in,out] ima The image whose domain extension is to be filled.
- *
- * \pre \p ima has to be initialized.
- */
+ /// Adjust then duplicate.
template <typename I, typename W>
void adjust_duplicate(const Image<I>& ima,
const Window<W>& win);
@@ -74,34 +66,6 @@
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
-
- template <typename I>
- void do_adjust_duplicate(const I& ima,
- unsigned delta)
- {
- mln_precondition(exact(ima).has_data());
- // mln_precondition(exact(win_like).is_valid());
-
- border::adjust(ima, delta);
- border::duplicate(ima);
- }
-
- template <typename I, typename W>
- void do_adjust_duplicate(const I& ima,
- const W& win_like)
- {
- mln_precondition(exact(ima).has_data());
- // mln_precondition(exact(win_like).is_valid());
-
- border::adjust(ima, geom::delta(win_like));
- border::duplicate(ima);
- }
-
- } // end of namespace mln::extension::impl
-
-
// Facades.
template <typename I, typename W>
@@ -109,7 +73,8 @@
const Window<W>& win)
{
trace::entering("extension::adjust_duplicate");
- impl::do_adjust_duplicate(ima, win);
+ extension::adjust(ima, win);
+ extension::duplicate(ima);
trace::exiting("extension::adjust_duplicate");
}
@@ -118,7 +83,8 @@
const Weighted_Window<W>& wwin)
{
trace::entering("extension::adjust_duplicate");
- impl::do_adjust_duplicate(ima, wwin);
+ extension::adjust(ima, wwin);
+ extension::duplicate(ima);
trace::exiting("extension::adjust_duplicate");
}
@@ -127,7 +93,8 @@
const Neighborhood<N>& nbh)
{
trace::entering("extension::adjust_duplicate");
- impl::do_adjust_duplicate(ima, nbh);
+ extension::adjust(ima, nbh);
+ extension::duplicate(ima);
trace::exiting("extension::adjust_duplicate");
}
@@ -136,7 +103,8 @@
unsigned delta)
{
trace::entering("extension::adjust_duplicate");
- impl::do_adjust_duplicate(ima, delta);
+ extension::adjust(ima, delta);
+ extension::duplicate(ima);
trace::exiting("extension::adjust_duplicate");
}
Index: mln/extension/all.hh
--- mln/extension/all.hh (revision 2813)
+++ mln/extension/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +28,11 @@
#ifndef MLN_EXTENSION_ALL_HH
# define MLN_EXTENSION_ALL_HH
-/*! \file mln/extension/all.hh
- *
- * \brief File that includes all extension materials.
- *
- * \todo Also include "extension images" + "extended"?
- */
+/// \file mln/extension/all.hh
+///
+/// \brief File that includes all extension materials.
+///
+/// \todo Also include "extension images" + "extended"?
namespace mln
@@ -45,8 +44,11 @@
} // end of namespace mln
+# include <mln/extension/adjust.hh>
# include <mln/extension/fill.hh>
# include <mln/extension/adjust_fill.hh>
+# include <mln/extension/duplicate.hh>
+# include <mln/extension/adjust_duplicate.hh>
#endif // ! MLN_EXTENSION_ALL_HH
Index: mln/extension/adjust.hh
--- mln/extension/adjust.hh (revision 2807)
+++ mln/extension/adjust.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,18 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_EXTENSION_ADJUST_FILL_HH
-# define MLN_CORE_EXTENSION_ADJUST_FILL_HH
+#ifndef MLN_CORE_EXTENSION_ADJUST_HH
+# define MLN_CORE_EXTENSION_ADJUST_HH
-/*! \file mln/extension/adjust_fill.hh
- *
- * \brief Adjust then fill the domain extension.
- *
- * \todo Fix doc.
- */
+/// \file mln/extension/adjust.hh
+///
+/// Adjust the domain extension to a minimum thickness border.
+///
+/// \todo Fix doc.
# include <mln/border/adjust.hh>
-# include <mln/extension/fill.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/core/concept/neighborhood.hh>
# include <mln/geom/delta.hh>
@@ -46,63 +47,39 @@
namespace extension
{
- /*! Fill the domain extension of image \p ima with the
- * single value \p v.
- *
- * \param[in,out] ima The image whose domain extension is to be filled.
- * \param[in] val The value to assign.
- *
- * \pre \p ima has to be initialized.
- *
- * \todo Optimize with memset if possible.
- */
+ /// Adjust the domain extension of image \p ima with the
+ /// size of the window \p win.
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Window<W>& win,
- const mln_value(I)& val);
+ void adjust(const Image<I>& ima, const Window<W>& win);
+ /// Adjust the domain extension of image \p ima with the
+ /// size of the weighted window \p wwin.
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Weighted_Window<W>& wwin,
- const mln_value(I)& val);
+ void adjust(const Image<I>& ima, const Weighted_Window<W>& wwin);
+ /// Adjust the domain extension of image \p ima with the
+ /// size of the neighborhood \p nbh.
template <typename I, typename N>
- void adjust_fill(const Image<I>& ima,
- const Neighborhood<N>& nbh,
- const mln_value(I)& val);
+ void adjust(const Image<I>& ima, const Neighborhood<N>& nbh);
+ /// Adjust the domain extension of image \p ima with the
+ /// size \p delta.
template <typename I>
- void adjust_fill(const Image<I>& ima,
- unsigned delta,
- const mln_value(I)& val);
+ void adjust(const Image<I>& ima, unsigned delta);
+
+
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
- template <typename I, typename V>
- void do_adjust_fill(const I& ima,
- unsigned delta,
- const V& val)
+ template <typename I>
+ void adjust(const I& ima, unsigned delta)
{
mln_precondition(exact(ima).has_data());
- // mln_precondition(exact(win_like).is_valid());
-
+ // FIXME: Is-it right?
border::adjust(ima, delta);
- extension::fill(ima, val);
- }
-
- template <typename I, typename W, typename V>
- void do_adjust_fill(const I& ima,
- const W& win_like,
- const V& val)
- {
- mln_precondition(exact(ima).has_data());
- // mln_precondition(exact(win_like).is_valid());
-
- border::adjust(ima, geom::delta(win_like));
- extension::fill(ima, val);
}
} // end of namespace mln::extension::impl
@@ -111,46 +88,37 @@
// Facades.
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Window<W>& win,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, win, val);
- trace::exiting("extension::adjust_fill");
+ void adjust(const Image<I>& ima, const Window<W>& win)
+ {
+ trace::entering("extension::adjust");
+ impl::adjust(ima, geom::delta(win));
+ trace::exiting("extension::adjust");
}
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Weighted_Window<W>& wwin,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, wwin, val);
- trace::exiting("extension::adjust_fill");
+ void adjust(const Image<I>& ima, const Weighted_Window<W>& wwin)
+ {
+ trace::entering("extension::adjust");
+ impl::adjust(ima, geom::delta(wwin));
+ trace::exiting("extension::adjust");
}
template <typename I, typename N>
- void adjust_fill(const Image<I>& ima,
- const Neighborhood<N>& nbh,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, nbh, val);
- trace::exiting("extension::adjust_fill");
+ void adjust(const Image<I>& ima, const Neighborhood<N>& nbh)
+ {
+ trace::entering("extension::adjust");
+ impl::adjust(ima, geom::delta(nbh));
+ trace::exiting("extension::adjust");
}
template <typename I>
- void adjust_fill(const Image<I>& ima,
- unsigned delta,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, delta, val);
- trace::exiting("extension::adjust_fill");
+ void adjust(const Image<I>& ima, unsigned delta)
+ {
+ trace::entering("extension::adjust");
+ impl::adjust(ima, delta);
+ trace::exiting("extension::adjust");
}
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::extension
@@ -158,4 +126,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_EXTENSION_FILL_HH
+#endif // ! MLN_CORE_EXTENSION_ADJUST_HH
Property changes on: mln/extension/adjust.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/extension/duplicate.hh
--- mln/extension/duplicate.hh (revision 0)
+++ mln/extension/duplicate.hh (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_EXTENSION_DUPLICATE_HH
+# define MLN_CORE_EXTENSION_DUPLICATE_HH
+
+/// \file mln/extension/duplicate.hh
+///
+/// Duplicate the values of the image inner boundary in the domain
+/// extension.
+///
+/// \todo Fix doc.
+
+# include <mln/border/duplicate.hh>
+
+
+namespace mln
+{
+
+ namespace extension
+ {
+
+ /// Assign the contents of the domain extension by duplicating the
+ /// values of the inner boundary of image \p ima.
+ template <typename I>
+ void duplicate(const Image<I>& ima);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade.
+
+ template <typename I>
+ void duplicate(const Image<I>& ima)
+ {
+ trace::entering("extension::duplicate");
+ border::duplicate(ima);
+ trace::exiting("extension::duplicate");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::extension
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_EXTENSION_DUPLICATE_HH
Index: mln/extension/adjust_fill.hh
--- mln/extension/adjust_fill.hh (revision 2813)
+++ mln/extension/adjust_fill.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,16 +28,14 @@
#ifndef MLN_CORE_EXTENSION_ADJUST_FILL_HH
# define MLN_CORE_EXTENSION_ADJUST_FILL_HH
-/*! \file mln/extension/adjust_fill.hh
- *
- * \brief Adjust then fill the domain extension.
- *
- * \todo Fix doc.
- */
+/// \file mln/extension/adjust_fill.hh
+///
+/// Adjust then fill the domain extension.
+///
+/// \todo Fix doc.
-# include <mln/border/adjust.hh>
+# include <mln/extension/adjust.hh>
# include <mln/extension/fill.hh>
-# include <mln/geom/delta.hh>
namespace mln
@@ -46,16 +44,7 @@
namespace extension
{
- /*! Fill the domain extension of image \p ima with the
- * single value \p v.
- *
- * \param[in,out] ima The image whose domain extension is to be filled.
- * \param[in] val The value to assign.
- *
- * \pre \p ima has to be initialized.
- *
- * \todo Optimize with memset if possible.
- */
+ /// Adjust then fill.
template <typename I, typename W>
void adjust_fill(const Image<I>& ima,
const Window<W>& win,
@@ -76,37 +65,8 @@
unsigned delta,
const mln_value(I)& val);
-# ifndef MLN_INCLUDE_ONLY
-
- namespace impl
- {
-
- template <typename I, typename V>
- void do_adjust_fill(const I& ima,
- unsigned delta,
- const V& val)
- {
- mln_precondition(exact(ima).has_data());
- // mln_precondition(exact(win_like).is_valid());
-
- border::adjust(ima, delta);
- extension::fill(ima, val);
- }
-
- template <typename I, typename W, typename V>
- void do_adjust_fill(const I& ima,
- const W& win_like,
- const V& val)
- {
- mln_precondition(exact(ima).has_data());
- // mln_precondition(exact(win_like).is_valid());
-
- border::adjust(ima, geom::delta(win_like));
- extension::fill(ima, val);
- }
-
- } // end of namespace mln::extension::impl
+# ifndef MLN_INCLUDE_ONLY
// Facades.
@@ -116,7 +76,8 @@
const mln_value(I)& val)
{
trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, win, val);
+ extension::adjust(ima, win);
+ extension::fill(ima, val);
trace::exiting("extension::adjust_fill");
}
@@ -126,7 +87,8 @@
const mln_value(I)& val)
{
trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, wwin, val);
+ extension::adjust(ima, wwin);
+ extension::fill(ima, val);
trace::exiting("extension::adjust_fill");
}
@@ -136,7 +98,8 @@
const mln_value(I)& val)
{
trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, nbh, val);
+ extension::adjust(ima, nbh);
+ extension::fill(ima, val);
trace::exiting("extension::adjust_fill");
}
@@ -146,7 +109,8 @@
const mln_value(I)& val)
{
trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, delta, val);
+ extension::adjust(ima, delta);
+ extension::fill(ima, val);
trace::exiting("extension::adjust_fill");
}
@@ -158,4 +122,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_EXTENSION_FILL_HH
+#endif // ! MLN_CORE_EXTENSION_ADJUST_FILL_HH
Index: mln/util/ord.hh
--- mln/util/ord.hh (revision 2813)
+++ mln/util/ord.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,10 @@
#ifndef MLN_UTIL_ORD_HH
# define MLN_UTIL_ORD_HH
-/*! \file mln/util/ord.hh
- *
- * \brief Definition of an ordering type and routine.
- */
+/// \file mln/util/ord.hh
+///
+/// Definition of an ordering type and routine.
+
# include <mln/core/concept/object.hh>
# include <mln/trait/op/ord.hh>
@@ -45,7 +45,7 @@
{
/// Function-object that defines an ordering between objects with
- /// type \p T.
+ /// type \p T: \a lhs R \a rhs. Its meaning is "lhs less-than rhs."
template <typename T>
struct ord
{
@@ -54,9 +54,12 @@
+ /// Routine to test if \a lhs is strictly "less-than" \a rhs.
template <typename T>
bool ord_strict(const T& lhs, const T& rhs);
+
+ /// Routine to test if \a lhs is "less-than or equal-to" \a rhs.
template <typename T>
bool ord_weak(const T& lhs, const T& rhs);
Index: mln/util/max.hh
--- mln/util/max.hh (revision 0)
+++ mln/util/max.hh (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_MAX_HH
+# define MLN_UTIL_MAX_HH
+
+/// \file mln/util/max.hh
+///
+/// Definition of a binary max based on the ordering relationship.
+
+# include <mln/util/ord.hh>
+
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+
+ template <typename T>
+ bool max(const T& lhs, const T& rhs);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ bool max(const T& lhs, const T& rhs)
+ {
+ return ord_strict(lhs, rhs) ? lhs : rhs;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_MAX_HH
1
0
cleanup-2008 2813: Fix missing include in gdpoint and void as lvalue in point wise image.
by Alexandre Abraham 05 Nov '08
by Alexandre Abraham 05 Nov '08
05 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Fix missing include in gdpoint and void as lvalue in point wise image.
* mln/core/concept/gdpoint.hh:
Add missing header.
* mln/pw/image.hh:
Remove void as lvalue.
core/concept/gdpoint.hh | 4 ++--
pw/image.hh | 13 +++++++------
2 files changed, 9 insertions(+), 8 deletions(-)
Index: mln/core/concept/gdpoint.hh
--- mln/core/concept/gdpoint.hh (revision 2812)
+++ mln/core/concept/gdpoint.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/object.hh>
# include <mln/core/grids.hh>
# include <mln/trait/all.hh>
-
+# include <mln/value/scalar.hh>
namespace mln
{
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 2812)
+++ mln/pw/image.hh (working copy)
@@ -132,7 +132,7 @@
typedef mln_result(F) rvalue;
/// Return type of read-write access.
- typedef void lvalue; // FIXME
+ typedef rvalue lvalue;
/// Constructor without argument.
image();
@@ -152,8 +152,8 @@
/// Read-only access of pixel value at point site \p p.
mln_result(F) operator()(const mln_psite(S)& p) const;
- /// Read-write access is present but disabled.
- void operator()(const mln_psite(S)&);
+ /// Read-write access is present but return a temporary value.
+ mln_result(F) operator()(const mln_psite(S)&);
};
} // end of namespace mln::pw
@@ -267,10 +267,11 @@
template <typename F, typename S>
inline
- void
- image<F,S>::operator()(const mln_psite(S)&)
+ mln_result(F)
+ image<F,S>::operator()(const mln_psite(S)& p)
{
- mln_invariant(0); // FIXME: Turn into a compile-time error...
+ mln_precondition(this->data_->pset_.has(p));
+ return this->data_->f_(p);
}
} // end of namespace mln::pw
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Supress non-critical std::size_t.
Mainly replace size_t nsites() by unsigned nsites().
Arguable, but make it compile on 64bits.
* mln/topo/complex.hh,
* mln/core/site_set/p_complex.hh,
* mln/core/site_set/p_line_graph.hh,
* mln/core/site_set/p_priority.hh,
* mln/core/site_set/p_faces.hh,
* mln/core/site_set/p_queue.hh,
* mln/core/site_set/p_key.hh,
* mln/core/site_set/p_queue_fast.hh,
* mln/core/site_set/p_graph.hh,
* mln/core/site_set/p_bgraph.hh,
* mln/core/site_set/p_run.hh,
* mln/core/site_set/p_line2d.hh,
* mln/core/site_set/p_array.hh,
* mln/core/site_set/p_vertices.hh,
* mln/core/site_set/p_edges.hh,
* mln/core/site_set/p_set.hh,
* mln/core/image/image1d.hh,
* mln/core/image/fi_adaptor.hh,
* mln/core/concept/box.hh,
* mln/core/concept/doc/image.hh,
* mln/core/concept/doc/box.hh,
* mln/core/concept/doc/image_fastest.hh,
* mln/core/concept/image.hh,
* mln/core/concept/site_set.hh,
* mln/level/paste.spe.hh,
* mln/convert/to_image.hh: Supress non-critical size_t.
convert/to_image.hh | 8 ++++----
core/concept/box.hh | 6 +++---
core/concept/doc/box.hh | 2 +-
core/concept/doc/image.hh | 2 +-
core/concept/doc/image_fastest.hh | 2 +-
core/concept/image.hh | 4 ++--
core/concept/site_set.hh | 2 +-
core/image/fi_adaptor.hh | 4 ++--
core/image/image1d.hh | 4 ++--
core/site_set/p_array.hh | 7 ++++---
core/site_set/p_bgraph.hh | 8 ++++----
core/site_set/p_complex.hh | 10 ++++------
core/site_set/p_edges.hh | 8 ++++----
core/site_set/p_faces.hh | 10 ++++------
core/site_set/p_graph.hh | 14 ++++++--------
core/site_set/p_key.hh | 6 +++---
core/site_set/p_line2d.hh | 4 ++--
core/site_set/p_line_graph.hh | 12 ++++++------
core/site_set/p_priority.hh | 6 +++---
core/site_set/p_queue.hh | 4 ++--
core/site_set/p_queue_fast.hh | 10 +++++-----
core/site_set/p_run.hh | 6 +++---
core/site_set/p_set.hh | 4 ++--
core/site_set/p_vertices.hh | 10 ++++------
level/paste.spe.hh | 2 +-
topo/complex.hh | 12 ++++++------
26 files changed, 80 insertions(+), 87 deletions(-)
Index: mln/topo/complex.hh
--- mln/topo/complex.hh (revision 2811)
+++ mln/topo/complex.hh (working copy)
@@ -124,11 +124,11 @@
/// \{
/// \brief Return the total number of faces, whatever their
/// dimension.
- std::size_t nfaces() const;
+ unsigned nfaces() const;
/// \brief Return the number of \p N-faces.
template <unsigned N>
- std::size_t nfaces() const;
+ unsigned nfaces() const;
/// \}
/// \brief Dynamic manipulators.
@@ -141,7 +141,7 @@
/// since each n_faces_set is checked (the present implementation
/// does not provide a direct access to n_faces_set through a
/// dynamic value of the dimension).
- std::size_t nfaces(unsigned n) const;
+ unsigned nfaces(unsigned n) const;
/// \}
/// Pretty-printing.
@@ -578,7 +578,7 @@
template <unsigned D>
inline
- std::size_t
+ unsigned
complex<D>::nfaces() const
{
return fold_left_(internal::add_size(), 0);
@@ -587,7 +587,7 @@
template <unsigned D>
template <unsigned N>
inline
- std::size_t
+ unsigned
complex<D>::nfaces() const
{
return data_->internal::faces_set_mixin<N, D>::faces_.size();
@@ -600,7 +600,7 @@
template <unsigned D>
inline
- std::size_t
+ unsigned
complex<D>::nfaces(unsigned n) const
{
// Ensure N is compatible with D.
Index: mln/core/site_set/p_complex.hh
--- mln/core/site_set/p_complex.hh (revision 2811)
+++ mln/core/site_set/p_complex.hh (working copy)
@@ -147,12 +147,10 @@
/// (Required by the mln::Site_Set concept, since the property
/// trait::site_set::nsites::known of this site set is set to
/// `known'.)
- /* FIXME: Return type should be std::size_t (see
- mln/core/concept/site_set.hh). */
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of faces in the complex.
- std::size_t nfaces() const;
+ unsigned nfaces() const;
// FIXME: Add nfaces(unsigned) routines? Yes, if this can
// simplify (and lighten) the implementation of piters, psites,
@@ -236,7 +234,7 @@
template <unsigned D, typename G>
inline
- std::size_t
+ unsigned
p_complex<D, G>::nsites() const
{
return nfaces();
@@ -244,7 +242,7 @@
template <unsigned D, typename G>
inline
- std::size_t
+ unsigned
p_complex<D, G>::nfaces() const
{
return cplx_.nfaces();
Index: mln/core/site_set/p_line_graph.hh
--- mln/core/site_set/p_line_graph.hh (revision 2811)
+++ mln/core/site_set/p_line_graph.hh (working copy)
@@ -109,12 +109,12 @@
/// `known'.)
/* FIXME: Return type should be std::size_t (see
mln/core/concept/site_set.hh). */
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of vertices in the graph.
- std::size_t nvertices() const;
+ unsigned nvertices() const;
/// Return The number of edges in the graph.
- std::size_t nedges() const;
+ unsigned nedges() const;
/// Is this site set valid?
bool is_valid() const;
@@ -196,7 +196,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_line_graph<P>::nsites() const
{
return nedges();
@@ -204,7 +204,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_line_graph<P>::nvertices() const
{
return this->gr_->nvertices();
@@ -212,7 +212,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_line_graph<P>::nedges() const
{
return this->gr_->nedges();
Index: mln/core/site_set/p_priority.hh
--- mln/core/site_set/p_priority.hh (revision 2811)
+++ mln/core/site_set/p_priority.hh (working copy)
@@ -114,7 +114,7 @@
bool is_valid() const;
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Push in the queue with \p priority the element \p e.
@@ -181,7 +181,7 @@
util::set<P> p_;
q_type_ q_;
- std::size_t n_;
+ unsigned n_;
// Run invariance tests and return the result.
bool run_() const;
@@ -225,7 +225,7 @@
template <typename P, typename Q>
inline
- std::size_t
+ unsigned
p_priority<P,Q>::nsites() const
{
mln_invariant(run_());
Index: mln/core/site_set/p_faces.hh
--- mln/core/site_set/p_faces.hh (revision 2811)
+++ mln/core/site_set/p_faces.hh (working copy)
@@ -118,12 +118,10 @@
/// (Required by the mln::Site_Set concept, since the property
/// trait::site_set::nsites::known of this site set is set to
/// `known'.)
- /* FIXME: Return type should be std::size_t (see
- mln/core/concept/site_set.hh). */
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of faces in the complex.
- std::size_t nfaces() const;
+ unsigned nfaces() const;
// FIXME: Add nfaces(unsigned) routines? Yes, if this can
// simplify (and lighten) the implementation of piters, psites,
@@ -212,7 +210,7 @@
template <unsigned N, unsigned D, typename P>
inline
- std::size_t
+ unsigned
p_faces<N, D, P>::nsites() const
{
return nfaces();
@@ -220,7 +218,7 @@
template <unsigned N, unsigned D, typename P>
inline
- std::size_t
+ unsigned
p_faces<N, D, P>::nfaces() const
{
return cplx_.template nfaces<N>();
Index: mln/core/site_set/p_queue.hh
--- mln/core/site_set/p_queue.hh (revision 2811)
+++ mln/core/site_set/p_queue.hh (working copy)
@@ -108,7 +108,7 @@
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Push a site \p p in the queue.
@@ -195,7 +195,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_queue<P>::nsites() const
{
return q_.size();
Index: mln/core/site_set/p_key.hh
--- mln/core/site_set/p_key.hh (revision 2811)
+++ mln/core/site_set/p_key.hh (working copy)
@@ -115,7 +115,7 @@
bool is_valid() const;
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Insertion element associated type.
@@ -192,7 +192,7 @@
k_t k_;
// Number of sites.
- std::size_t n_;
+ unsigned n_;
// Run invariance tests and return the result.
bool run_() const;
@@ -245,7 +245,7 @@
template <typename K, typename P>
inline
- std::size_t
+ unsigned
p_key<K,P>::nsites() const
{
mln_invariant(run_());
Index: mln/core/site_set/p_queue_fast.hh
--- mln/core/site_set/p_queue_fast.hh (revision 2811)
+++ mln/core/site_set/p_queue_fast.hh (working copy)
@@ -95,7 +95,7 @@
p_queue_fast();
/// Reserve \p n cells.
- void reserve(std::size_t n);
+ void reserve(typename p_array<P>::size_type n);
/// Test if \p p belongs to this site set.
bool has(const psite& p) const;
@@ -110,7 +110,7 @@
bool compute_has(const P& p) const;
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Push a site \p p in the queue.
@@ -175,9 +175,9 @@
template <typename P>
inline
void
- p_queue_fast<P>::reserve(std::size_t n)
+ p_queue_fast<P>::reserve(typename p_array<P>::size_type n)
{
- q_.reserve();
+ q_.reserve(n);
}
template <typename P>
@@ -236,7 +236,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_queue_fast<P>::nsites() const
{
mln_invariant(end_ >= begin_);
Index: mln/core/site_set/p_graph.hh
--- mln/core/site_set/p_graph.hh (revision 2811)
+++ mln/core/site_set/p_graph.hh (working copy)
@@ -101,14 +101,12 @@
/// the number of \em vertices.
///
/// Required by the mln::Point_Set concept.
- /* FIXME: Return type should be std::size_t (see
- mln/core/concept/site_set.hh). */
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of vertices in the graph.
- std::size_t nvertices() const;
+ unsigned nvertices() const;
/// Return The number of edges in the graph.
- std::size_t nedges() const;
+ unsigned nedges() const;
/// Is this site set valid?
bool is_valid() const;
@@ -207,7 +205,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_graph<P>::nsites() const
{
return nvertices();
@@ -215,7 +213,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_graph<P>::nvertices() const
{
return this->gr_->nvertices();
@@ -223,7 +221,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_graph<P>::nedges() const
{
return this->gr_->nedges();
Index: mln/core/site_set/p_bgraph.hh
--- mln/core/site_set/p_bgraph.hh (revision 2811)
+++ mln/core/site_set/p_bgraph.hh (working copy)
@@ -78,10 +78,10 @@
p_bgraph (graph* gr);
/// Return The number of points (i.e., nodes) in the graph.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of lines (i.e., edges) in the graph.
- std::size_t nlines() const;
+ unsigned nlines() const;
/// Give the exact bounding box.
const box<P>& bbox() const;
@@ -130,7 +130,7 @@
template<typename P>
inline
- std::size_t
+ unsigned
p_bgraph<P>::nsites() const
{
return boost::num_vertices(*gr_);
@@ -138,7 +138,7 @@
template<typename P>
inline
- std::size_t
+ unsigned
p_bgraph<P>::nlines() const
{
return boost::num_edges(gr_->nedges());
Index: mln/core/site_set/p_run.hh
--- mln/core/site_set/p_run.hh (revision 2811)
+++ mln/core/site_set/p_run.hh (working copy)
@@ -128,7 +128,7 @@
bool has_index(unsigned short i) const;
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Give the length of the run.
unsigned short length() const;
@@ -162,7 +162,7 @@
P start_;
/// The length of the run.
- std::size_t len_;
+ unsigned len_;
};
@@ -307,7 +307,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_run<P>::nsites() const
{
mln_precondition(is_valid());
Index: mln/core/site_set/p_line2d.hh
--- mln/core/site_set/p_line2d.hh (revision 2811)
+++ mln/core/site_set/p_line2d.hh (working copy)
@@ -112,7 +112,7 @@
/// Give the number of points.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Give the point that begins the line.
const point2d& begin() const;
@@ -252,7 +252,7 @@
}
inline
- std::size_t
+ unsigned
p_line2d::nsites() const
{
return arr_.nsites();
Index: mln/core/site_set/p_array.hh
--- mln/core/site_set/p_array.hh (revision 2811)
+++ mln/core/site_set/p_array.hh (working copy)
@@ -83,6 +83,7 @@
{
typedef p_array<P> self_;
public:
+ typedef typename std::vector<P>::size_type size_type;
/// Element associated type.
typedef P element;
@@ -108,7 +109,7 @@
/// Reserve \p n cells.
- void reserve(std::size_t n);
+ void reserve(size_type n);
/// Test is \p p belongs to this site set.
@@ -125,7 +126,7 @@
void change(const psite& p, const P& new_p);
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Append a point \p p.
@@ -338,7 +339,7 @@
template <typename P>
inline
void
- p_array<P>::reserve(std::size_t n)
+ p_array<P>::reserve(size_type n)
{
vect_.reserve(n);
}
Index: mln/core/site_set/p_vertices.hh
--- mln/core/site_set/p_vertices.hh (revision 2811)
+++ mln/core/site_set/p_vertices.hh (working copy)
@@ -104,12 +104,10 @@
/// the number of \em vertices.
///
/// Required by the mln::Point_Set concept.
- /* FIXME: Return type should be std::size_t (see
- mln/core/concept/site_set.hh). */
- size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of vertices in the graph.
- std::size_t nvertices() const;
+ unsigned nvertices() const;
/// Is this site set valid?
bool is_valid() const;
@@ -191,7 +189,7 @@
template <typename G, typename F>
inline
- size_t
+ unsigned
p_vertices<G, F>::nsites() const
{
return nvertices();
@@ -199,7 +197,7 @@
template <typename G, typename F>
inline
- std::size_t
+ unsigned
p_vertices<G, F>::nvertices() const
{
return this->g_->v_nmax();
Index: mln/core/site_set/p_edges.hh
--- mln/core/site_set/p_edges.hh (revision 2811)
+++ mln/core/site_set/p_edges.hh (working copy)
@@ -94,10 +94,10 @@
/// \brief Return The number of points (sites) of the set, i.e.,
/// the number of \em edges.
- size_t nsites() const;
+ unsigned nsites() const;
/// Return The number of edges in the graph.
- std::size_t nedges() const;
+ unsigned nedges() const;
/// Is this site set valid?
bool is_valid() const;
@@ -162,7 +162,7 @@
template <typename G, typename F>
inline
- size_t
+ unsigned
p_edges<G, F>::nsites() const
{
return nedges();
@@ -170,7 +170,7 @@
template <typename G, typename F>
inline
- std::size_t
+ unsigned
p_edges<G, F>::nedges() const
{
return this->g_->e_nmax();
Index: mln/core/site_set/p_set.hh
--- mln/core/site_set/p_set.hh (revision 2811)
+++ mln/core/site_set/p_set.hh (working copy)
@@ -107,7 +107,7 @@
/// Give the number of sites.
- std::size_t nsites() const;
+ unsigned nsites() const;
/// Insertion element associated type.
@@ -192,7 +192,7 @@
template <typename P>
inline
- std::size_t
+ unsigned
p_set<P>::nsites() const
{
return s_.nelements();
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2811)
+++ mln/core/image/image1d.hh (working copy)
@@ -213,7 +213,7 @@
T& element(unsigned ind);
/// Give the number of cells (points including border ones).
- std::size_t nelements() const;
+ unsigned nelements() const;
@@ -389,7 +389,7 @@
template <typename T>
inline
- std::size_t
+ unsigned
image1d<T>::nelements() const
{
mln_precondition(this->has_data());
Index: mln/core/image/fi_adaptor.hh
--- mln/core/image/fi_adaptor.hh (revision 2811)
+++ mln/core/image/fi_adaptor.hh (working copy)
@@ -170,7 +170,7 @@
const box2d& domain() const;
/// Give the number of cells.
- std::size_t nelements() const;
+ unsigned nelements() const;
/// Read-only access to the image value located at point \p p.
const T& operator()(const point2d& p) const;
@@ -306,7 +306,7 @@
}
template <typename I>
- std::size_t
+ unsigned
fi_adaptor<I>::nelements() const
{
mln_precondition(this->has_data());
Index: mln/core/concept/box.hh
--- mln/core/concept/box.hh (revision 2811)
+++ mln/core/concept/box.hh (working copy)
@@ -82,7 +82,7 @@
*
* \warning This method is final for all box classes.
*/
- std::size_t nsites() const;
+ unsigned nsites() const;
protected:
Box();
@@ -157,12 +157,12 @@
template <typename E>
inline
- std::size_t
+ unsigned
Box<E>::nsites() const
{
if (! exact(this)->is_valid())
return 0;
- std::size_t count = 1;
+ unsigned count = 1;
typedef mln_site(E) P; // Helps g++-3.3.5.
for (unsigned i = 0; i < P::dim; ++i)
count *= exact(this)->len(i);
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 2811)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -176,7 +176,7 @@
/*! \brief Give the number of points of the image domain.
*/
- std::size_t nsites() const;
+ unsigned nsites() const;
};
Index: mln/core/concept/doc/box.hh
--- mln/core/concept/doc/box.hh (revision 2811)
+++ mln/core/concept/doc/box.hh (working copy)
@@ -74,7 +74,7 @@
*
* \warning This method is final for all box classes.
*/
- std::size_t nsites() const;
+ unsigned nsites() const;
};
} // end of namespace mln::doc
Index: mln/core/concept/doc/image_fastest.hh
--- mln/core/concept/doc/image_fastest.hh (revision 2811)
+++ mln/core/concept/doc/image_fastest.hh (working copy)
@@ -106,7 +106,7 @@
*
* \pre The image has to be initialized.
*/
- std::size_t nelements() const;
+ unsigned nelements() const;
};
} // end of namespace mln::doc
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2811)
+++ mln/core/concept/image.hh (working copy)
@@ -86,7 +86,7 @@
typedef bkd_piter;
bool has(const psite& p) const;
- std::size_t nsites() const; // If relevant.
+ unsigned nsites() const; // If relevant.
bool has_data() const;
@@ -194,7 +194,7 @@
m1 = 0;
// Only some image types feature the 'nsites' method.
-// std::size_t (E::*m2)() const = & E::nsites;
+// unsigned (E::*m2)() const = & E::nsites;
// m2 = 0;
bool (E::*m3)() const = & E::has_data;
Index: mln/core/concept/site_set.hh
--- mln/core/concept/site_set.hh (revision 2811)
+++ mln/core/concept/site_set.hh (working copy)
@@ -186,7 +186,7 @@
{
static void run()
{
- std::size_t (E::*m)() const = & E::nsites;
+ unsigned (E::*m)() const = & E::nsites;
m = 0;
}
};
Index: mln/level/paste.spe.hh
--- mln/level/paste.spe.hh (revision 2811)
+++ mln/level/paste.spe.hh (working copy)
@@ -77,7 +77,7 @@
// {
// trace::entering("level::impl::paste_lines_");
// typedef mln_psite(I) P;
-// std::size_t n = data.bbox().len(P::dim - 1);
+// unsigned n = data.bbox().len(P::dim - 1);
// // FIXME: Works only for raw data images
// // FIXME: For linear data images, we should get the len for each line...
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh (revision 2811)
+++ mln/convert/to_image.hh (working copy)
@@ -77,9 +77,9 @@
mln_image_from_grid(mln_site(N)::grid, bool)
to_image(const Neighborhood<N>& nbh);
- /// Convert an histo \p h into an image1d<std::size_t>.
+ /// Convert an histo \p h into an image1d<unsigned>.
template <typename T>
- image1d<std::size_t>
+ image1d<unsigned>
to_image(const histo::data<T>& h);
@@ -136,12 +136,12 @@
template <typename T>
inline
- image1d<std::size_t>
+ image1d<unsigned>
to_image(const histo::data<T>& h)
{
T v_min = h.vset()[0],
v_max = h.vset()[h.vset().nvalues() - 1];
- image1d<std::size_t> ima(make::box1d(v_min, v_max));
+ image1d<unsigned> ima(make::box1d(v_min, v_max));
for (unsigned i = 0; i < h.vset().nvalues(); ++i)
ima(point1d(i)) = h[i];
return ima;
1
0
05 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM: CLassif: Reduce nb of included files.
* inim/classif/display.hh,
* inim/classif/iccvg04.cc,
* inim/classif/v2.cc,: Rewrite geom inclusion.
display.hh | 4 +++-
iccvg04.cc | 4 +++-
v2.cc | 5 ++++-
3 files changed, 10 insertions(+), 3 deletions(-)
Index: inim/classif/display.hh
--- inim/classif/display.hh (revision 2810)
+++ inim/classif/display.hh (working copy)
@@ -29,7 +29,9 @@
# define MLN__DISPLAY_HH
#include <mln/io/ppm/save.hh>
-#include <mln/geom/all.hh>
+#include <mln/geom/nrows.hh>
+#include <mln/geom/ncols.hh>
+#include <mln/geom/nslis.hh>
#include <mln/value/all.hh>
#include <mln/core/image/image3d.hh>
Index: inim/classif/iccvg04.cc
--- inim/classif/iccvg04.cc (revision 2810)
+++ inim/classif/iccvg04.cc (working copy)
@@ -18,7 +18,9 @@
#include <mln/util/array.hh>
#include <mln/labeling/compute.hh>
-#include <mln/geom/all.hh>
+#include <mln/geom/nrows.hh>
+#include <mln/geom/ncols.hh>
+#include <mln/geom/nslis.hh>
#include <mln/io/ppm/load.hh>
#include <mln/io/pgm/save.hh>
Index: inim/classif/v2.cc
--- inim/classif/v2.cc (revision 2810)
+++ inim/classif/v2.cc (working copy)
@@ -5,7 +5,10 @@
#include <mln/value/all.hh>
#include <mln/level/fill.hh>
-#include <mln/geom/all.hh>
+#include <mln/geom/nrows.hh>
+#include <mln/geom/ncols.hh>
+#include <mln/geom/nslis.hh>
+
#include <mln/io/ppm/load.hh>
#include <mln/io/pgm/save.hh>
1
0
Re: [Olena-patches] cleanup-2008 2806: #87 Add unit (sanity) tests to Milena.
by Thierry GERAUD 05 Nov '08
by Thierry GERAUD 05 Nov '08
05 Nov '08
Ugo Jardonnet wrote:
> https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
>
>
super :-)
1
0
* mln/core/dpsites_piter.hh: use std_vector() instead of to_vec().
---
milena/ChangeLog | 6 ++++++
milena/mln/core/dpsites_piter.hh | 10 +++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f15caeb..e736568 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix compilation issue.
+
+ * mln/core/dpsites_piter.hh: use std_vector() instead of to_vec().
+
2008-11-05 Nicolas Ballas <ballas(a)lrde.epita.fr>
Use memcpy_ in level::fill_with_image.
diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh
index 07a9cc2..99d95f5 100644
--- a/milena/mln/core/dpsites_piter.hh
+++ b/milena/mln/core/dpsites_piter.hh
@@ -155,7 +155,7 @@ namespace mln
bool
dpsites_fwd_piter<V>::is_valid_() const
{
- return i_ != this->s_->to_vec().size();
+ return i_ != this->s_->std_vector().size();
}
template <typename V>
@@ -163,7 +163,7 @@ namespace mln
void
dpsites_fwd_piter<V>::invalidate_()
{
- i_ = this->s_->to_vec().size();
+ i_ = this->s_->std_vector().size();
}
template <typename V>
@@ -187,7 +187,7 @@ namespace mln
mln_psite(V)
dpsites_fwd_piter<V>::compute_p_() const
{
- return *this->c_ + this->s_->to_vec()[i_];
+ return *this->c_ + this->s_->std_vector()[i_];
}
@@ -229,7 +229,7 @@ namespace mln
void
dpsites_bkd_piter<V>::do_start_()
{
- i_ = this->s_->to_vec().size() - 1;
+ i_ = this->s_->std_vector().size() - 1;
}
template <typename V>
@@ -245,7 +245,7 @@ namespace mln
mln_psite(V)
dpsites_bkd_piter<V>::compute_p_() const
{
- return *this->c_ + this->s_->to_vec()[i_];
+ return *this->c_ + this->s_->std_vector()[i_];
}
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0