Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* oln/utils/qsort.hh: Add file.
* oln/utils/histogram.hh: Undo wrong fix.
+2004-05-23 Giovanni Palma <giovanni(a)lrde.epita.fr>
+
+ * oln/morpho/morpho/erosion.hh: Remove useless line.
* oln/morpho/attribute_union_find.hh: Change sort algorithm.
* oln/morpho/attributes.hh: Add volume attribute.
- * oln/utils/qsort.hh: Add file.
2004-05-15 Niels Van Vliet <niels(a)lrde.epita.fr>
Index: olena/oln/utils/histogram.hh
--- olena/oln/utils/histogram.hh Sun, 23 May 2004 12:21:34 +0200 palma_g
(oln/10_histogram. 1.6.1.14.1.13 640)
+++ olena/oln/utils/histogram.hh Sun, 23 May 2004 13:51:52 +0200 palma_g
(oln/10_histogram. 1.6.1.14.1.13 640)
@@ -682,7 +682,7 @@
ensure_type;
// check the size
- precondition(v.size() == im/*.npoints()*/);
+ precondition(v.size() == im.npoints());
// calculate the histogram of the image
utils::histogram<val> histo(im);
Index: olena/oln/utils/qsort.hh
--- olena/oln/utils/qsort.hh Sun, 23 May 2004 13:54:21 +0200 palma_g ()
+++ olena/oln/utils/qsort.hh Sun, 23 May 2004 12:09:58 +0200 palma_g (oln/r/9_qsort.hh
644)
@@ -0,0 +1,161 @@
+// Copyright (C) 2004 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, 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 OLN_UTILS_QSORT_HH
+# define OLN_UTILS_QSORT_HH
+# include <vector>
+# include <oln/core/abstract/image.hh>
+
+# include <algorithm>
+# include <iostream>
+
+namespace oln
+{
+ namespace utils
+ {
+ namespace internal
+ {
+ /*!
+ ** \brief Functor to sort compare 2 points using an image.
+ **
+ ** \param I Exact type of the image.
+ */
+ template <typename I>
+ struct cmp_pt_value
+ {
+ typedef oln::abstract::non_vectorial_image<I> im_type; ///< Type of the image.
+ typedef oln_point_type(I) point_type; ///< Type of the considered points.
+
+ /*!
+ ** \brief Constructor.
+ **
+ ** \arg im Image to use for comparison.
+ */
+ cmp_pt_value(const im_type &im): im_(im)
+ {
+ }
+
+ /*!
+ ** \brief Main method.
+ **
+ ** \arg i The first point.
+ ** \arg j The second point.
+ ** \return im[i] < im[j]
+ */
+ bool operator()(const point_type &i, const point_type &j)
+ {
+ return im_[j] < im_[i];
+ }
+
+ protected:
+ const im_type &im_; ///< Image to use for comparison.
+ };
+
+ /*!
+ ** \brief Functor to sort compare 2 points using an image
+ **
+ ** \param I Exact type of the image.
+ */
+ template <typename I>
+ struct cmp_pt_value_inv
+ {
+ typedef oln::abstract::non_vectorial_image<I> im_type; ///< Type of the image.
+ typedef oln_point_type(I) point_type; ///< Type of the considered points.
+
+ /*!
+ ** \brief Constructor.
+ **
+ ** \arg im Image to use for comparison.
+ */
+ cmp_pt_value_inv(const im_type &im): im_(im)
+ {
+ }
+
+ /*!
+ ** \brief Main method.
+ **
+ ** \arg i The first point.
+ ** \arg j The second point.
+ ** \return im[i] > im[j]
+ */
+ bool operator()(const point_type &i, const point_type &j)
+ {
+ return im_[i] < im_[j];
+ }
+
+ protected:
+ const im_type &im_; ///< Image to use for comparison.
+ };
+ } // !internal
+
+ /*!
+ ** \brief Sort points of an image in increasing order.
+ **
+ ** \param I Exact type of the image.
+ **
+ ** \arg im The input image.
+ ** \arg v The result.
+ */
+ template<class I>
+ void
+ qsort(const oln::abstract::non_vectorial_image<I>& im,
+ std::vector<oln_point_type(I)> &v)
+ {
+ oln_iter_type(I) it(im);
+
+ for_all(it)
+ v.push_back(oln_point_type(I)(it));
+ internal::cmp_pt_value<I> c(im);
+
+ std::sort(v.begin(), v.end(), c);
+ }
+
+ /*!
+ ** \brief Sort points of an image in decreasing order.
+ **
+ ** \param I Exact type of the image.
+ **
+ ** \arg im The input image.
+ ** \arg v The result.
+ */
+ template<class I>
+ void
+ qsort_inv(const oln::abstract::non_vectorial_image<I>& im,
+ std::vector<oln_point_type(I)> &v)
+ {
+ oln_iter_type(I) it(im);
+
+ for_all(it)
+ v.push_back(oln_point_type(I)(it));
+
+ internal::cmp_pt_value_inv<I> c(im);
+
+ std::sort(v.begin(), v.end(), c);
+ }
+ } // !utils
+} // !oln
+
+#endif // !QSORT
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74