Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* tests/level: New.
* tests/level/tests: New.
* tests/level/tests/compare: New.
* tests/level/tests/fill: New.
* tests/level/runs: New.
* tests/level/Makefile.am: New.
* oln/makefile.src: Add new files.
* oln/level: New.
* oln/level/compare.hh: Add comparison operators for images.
* oln/level/fill.hh: Add fill function for images.
oln/level/compare.hh | 132 ++++++++++++++++++++++++++++++++++++++++++++++
oln/level/fill.hh | 53 ++++++++++++++++++
oln/makefile.src | 4 +
tests/level/Makefile.am | 4 +
tests/level/tests/compare | 76 ++++++++++++++++++++++++++
tests/level/tests/fill | 50 +++++++++++++++++
6 files changed, 318 insertions(+), 1 deletion(-)
Index: tests/level/tests/compare
--- tests/level/tests/compare (revision 0)
+++ tests/level/tests/compare (revision 0)
@@ -0,0 +1,76 @@
+// -*- c++ -*-
+// Copyright (C) 2002, 2003, 2004, 2005 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.
+
+#include <ntg/all.hh>
+#include <oln/basics2d.hh>
+#include <oln/level/fill.hh>
+#include <oln/level/compare.hh>
+#include <iostream>
+#include "check.hh"
+#include "data.hh"
+
+#define OK_OR_FAIL \
+ std::cout << "OK" << std::endl; \
+ else \
+ { \
+ std::cout << "FAIL" << std::endl; \
+ fail = true; \
+ }
+
+#define ASSERT_CHECK(Val) { assert_check(Val, #Val, fail); }
+
+void assert_check(bool res, const std::string& desc, bool &fail)
+{
+ std::cout << "---- " << desc << " ----" <<
std::endl;
+ if (res)
+ OK_OR_FAIL;
+}
+
+
+bool
+check(void)
+{
+ bool fail = false;
+
+ oln::image2d<ntg::int_u8>
+ im_0(16, 16),
+ im_20(16, 16);
+ oln::level::fill(im_0, 0);
+ oln::level::fill(im_20, 20);
+
+ ASSERT_CHECK(oln::level::is_greater(im_20, im_0));
+ ASSERT_CHECK(!oln::level::is_greater(im_0, im_20));
+ ASSERT_CHECK(oln::level::is_greater_or_equal(im_0, im_0));
+
+ ASSERT_CHECK(oln::level::is_lower(im_0, im_20));
+ ASSERT_CHECK(!oln::level::is_lower(im_20, im_0));
+ ASSERT_CHECK(oln::level::is_lower_or_equal(im_0, im_0));
+
+ ASSERT_CHECK(oln::level::is_equal(im_0, im_0));
+ return fail;
+}
Index: tests/level/tests/fill
--- tests/level/tests/fill (revision 0)
+++ tests/level/tests/fill (revision 0)
@@ -0,0 +1,50 @@
+// -*- c++ -*-
+// Copyright (C) 2002, 2003, 2004, 2005 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.
+
+#include <ntg/all.hh>
+#include <oln/basics2d.hh>
+#include <oln/level/fill.hh>
+#include <iostream>
+#include "check.hh"
+#include "data.hh"
+
+bool
+check(void)
+{
+
+ oln::image2d<ntg::int_u8> im(10, 10);
+
+ oln::level::fill(im, 51);
+
+ oln::fwd_piter2d it(im.size());
+ for_all(it)
+ if (im[it] != 51)
+ return true;
+
+ return false;
+}
Index: tests/level/Makefile.am
--- tests/level/Makefile.am (revision 0)
+++ tests/level/Makefile.am (revision 0)
@@ -0,0 +1,4 @@
+include ../check/Makefile.runtests
+
+CLEANFILES += cc 2nd_cc connected_out lena_inverted set_level \
+ set_level2 threshold_128
Index: oln/makefile.src
--- oln/makefile.src (revision 66)
+++ oln/makefile.src (working copy)
@@ -46,4 +46,6 @@
io/read_image_2d_pnm.hh \
io/utils.hh \
io/write_image.hh \
- io/write_image_2d_pnm.hh
+ io/write_image_2d_pnm.hh \
+ level/compare.hh \
+ level/fill.hh
Index: oln/level/compare.hh
--- oln/level/compare.hh (revision 0)
+++ oln/level/compare.hh (revision 0)
@@ -0,0 +1,132 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 OLENA_LEVEL_COMPARE_HH
+# define OLENA_LEVEL_COMPARE_HH
+
+# include <oln/basics.hh>
+
+namespace oln {
+
+ namespace level {
+
+ /*! \brief Tests if all pixels of input1 are greater or equal than input2.
+ **
+ ** \pre input1.size() == input2.size()
+ **/
+ template<class I1, class I2> inline
+ bool
+ is_greater_or_equal(const abstract::image<I1>& input1,
+ const abstract::image<I2>& input2)
+ {
+ precondition(input1.size() == input2.size());
+ oln_type_of(I1, fwd_piter) p(input1.size());
+
+ for_all (p)
+ if (!(input1[p] >= input2[p]))
+ return false;
+ return true;
+ }
+
+ /*! \brief Tests if all pixels of input1 are greater than input2.
+ **
+ ** \pre input1.size() == input2.size()
+ **/
+ template<class I1, class I2> inline
+ bool
+ is_greater(const abstract::image<I1>& input1,
+ const abstract::image<I2>& input2)
+ {
+ precondition(input1.size() == input2.size());
+ oln_type_of(I1, fwd_piter) p(input1.size());
+
+ for_all (p)
+ if (!(input1[p] > input2[p]))
+ return false;
+ return true;
+ }
+
+ /*! \brief Tests if all pixels of input1 are lower or equal than input2.
+ **
+ ** \pre input1.size() == input2.size()
+ **/
+ template<class I1, class I2> inline
+ bool
+ is_lower_or_equal(const abstract::image<I1>& input1,
+ const abstract::image<I2>& input2)
+ {
+ precondition(input1.size() == input2.size());
+ oln_type_of(I1, fwd_piter) p(input1.size());
+
+ for_all (p)
+ if (!(input1[p] <= input2[p]))
+ return false;
+ return true;
+ }
+
+ /*! \brief Tests if all pixel of input1 are lower than input2.
+ **
+ ** \pre input1.size() == input2.size()
+ **/
+ template<class I1, class I2> inline
+ bool
+ is_lower(const abstract::image<I1>& input1,
+ const abstract::image<I2>& input2)
+ {
+ precondition(input1.size() == input2.size());
+ oln_type_of(I1, fwd_piter) p(input1.size());
+
+ for_all (p)
+ if (!(input1[p] < input2[p]))
+ return false;
+ return true;
+ }
+
+
+ /*! \brief Tests if input1 is equal to input2.
+ **
+ ** \pre input1.size() == input2.size()
+ **/
+ template<class I1, class I2> inline
+ bool
+ is_equal(const abstract::image<I1>& input1,
+ const abstract::image<I2>& input2)
+ {
+ precondition(input1.size() == input2.size());
+ oln_type_of(I1, fwd_piter) p(input1.size());
+
+ for_all (p)
+ if (!(input1[p] == input2[p]))
+ return false;
+ return true;
+ }
+
+ } // end of namespace level
+
+} // end of namespace oln
+
+#endif // ! OLENA_LEVEL_COMPARE_HH
Index: oln/level/fill.hh
--- oln/level/fill.hh (revision 0)
+++ oln/level/fill.hh (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 OLENA_LEVEL_FILL_HH
+# define OLENA_LEVEL_FILL_HH
+
+# include <oln/basics.hh>
+
+namespace oln {
+
+ namespace level {
+
+ /*! \brief Fill the image with a value.
+ */
+ template <class I>
+ I
+ fill(abstract::image<I>& im, const oln_type_of(I, value)& val)
+ {
+ oln_type_of(I, fwd_piter) p(im.size());
+ for_all(p)
+ im[p] = val;
+ return im.exact();
+ }
+
+ } // end of namespace level
+
+} // end of namespace oln
+
+#endif // ! OLENA_LEVEL_FILL_HH