Commit 33be8ed3 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add accu::site_set::rectangularity.

	* mln/accu/all.hh,
	* mln/accu/essential.hh,
	* mln/accu/image/essential.hh,
	* mln/accu/site_set/all.hh,
	* mln/accu/site_set/essential.hh: update all and essential includes.

	* mln/accu/site_set/rectangularity.hh: new accumulator.

	* tests/accu/Makefile.am,
	* tests/accu/site_set/Makefile.am,
	* tests/accu/site_set/rectangularity.cc: add associated test.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3549 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 44d1c01d
2009-03-19 Guillaume Lazzara <lazzara@lrde.epita.fr>
Add accu::site_set::rectangularity.
* mln/accu/all.hh,
* mln/accu/essential.hh,
* mln/accu/image/essential.hh,
* mln/accu/site_set/all.hh,
* mln/accu/site_set/essential.hh: update all and essential includes.
* mln/accu/site_set/rectangularity.hh: new accumulator.
* tests/accu/Makefile.am,
* tests/accu/site_set/Makefile.am,
* tests/accu/site_set/rectangularity.cc: add associated test.
2009-03-19 Guillaume Lazzara <lazzara@lrde.epita.fr>
 
Add accu::couple.
......@@ -96,6 +96,7 @@ namespace mln
// Sub-directories
# include <mln/accu/image/all.hh>
# include <mln/accu/site_set/all.hh>
#endif // ! MLN_ACCU_ALL_HH
// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2008, 2009 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
......@@ -46,5 +46,8 @@
# include <mln/accu/rank.hh>
# include <mln/accu/sum.hh>
# include <mln/accu/image/essential.hh>
# include <mln/accu/site_set/essential.hh>
#endif // !MLN_ACCU_ESSENTIAL_HH_
// Copyright (C) 2009 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_ACCU_IMAGE_ESSENTIAL_HH_
# define MLN_ACCU_IMAGE_ESSENTIAL_HH_
/// \file mln/accu/image/essential.hh
///
/// File that includes the most useful accumulator types working on images.
#endif // !MLN_ACCU_IMAGE_ESSENTIAL_HH_
// Copyright (C) 2009 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_ACCU_SITE_SET_ALL_HH_
# define MLN_ACCU_SITE_SET_ALL_HH_
/// \file mln/accu/site_set/all.hh
///
/// File that includes all accumulator types working on site sets.
# include <mln/accu/site_set/rectangularity.hh>
#endif // !MLN_ACCU_SITE_SET_ALL_HH_
// Copyright (C) 2009 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_ACCU_SITE_SET_ESSENTIAL_HH_
# define MLN_ACCU_SITE_SET_ESSENTIAL_HH_
/// \file mln/accu/site_set/essential.hh
///
/// File that includes the most useful accumulator types working on site sets.
#endif // !MLN_ACCU_SITE_SET_ESSENTIAL_HH_
// Copyright (C) 2009 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_ACCU_SITE_SET_RECTANGULARITY_HH
# define MLN_ACCU_SITE_SET_RECTANGULARITY_HH
/// \file mln/accu/site_set/rectangularity.hh
///
/// Compute the rectangularity of a site set.
# include <mln/accu/internal/couple.hh>
# include <mln/accu/bbox.hh>
# include <mln/accu/count.hh>
namespace mln
{
namespace accu
{
namespace site_set
{
/// Compute the rectangularity of a site set.
template <typename P>
class rectangularity
: public accu::internal::couple<accu::bbox<P>,
accu::count<P>,
float,
rectangularity<P> >
{
public:
typedef accu::internal::couple<accu::bbox<P>,
accu::count<P>,
float,
rectangularity<P> > super_;
typedef accu::bbox<P> A1;
typedef accu::count<P> A2;
typedef float result;
/// Constructor
rectangularity();
/// Return the site set bounding box.
mln_result(A1) bbox() const;
/// Return the site set area.
mln_result(A2) area() const;
/// Return the rectangularity value.
result to_result() const;
protected:
using super_::a1_;
using super_::a2_;
};
# ifndef MLN_INCLUDE_ONLY
template <typename P>
inline
rectangularity<P>::rectangularity()
{
}
template <typename P>
inline
mln_result(rectangularity<P>::A1)
rectangularity<P>::bbox() const
{
mln_precondition(a1_.is_valid());
return a1_.to_result();
}
template <typename P>
inline
mln_result(rectangularity<P>::A2)
rectangularity<P>::area() const
{
mln_precondition(a2_.is_valid());
return a2_.to_result();
}
template <typename P>
inline
mln_result(rectangularity<P>)
rectangularity<P>::to_result() const
{
mln_precondition(this->is_valid());
// Force division return type.
return static_cast<result>(a2_.to_result()) / a1_.to_result().nsites();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu::site_set
} // end of namespace mln::accu
} // end of namespace mln
#endif // ! MLN_ACCU_SITE_SET_RECTANGULARITY_HH
......@@ -2,6 +2,10 @@
include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
image \
site_set
check_PROGRAMS = \
all_accus \
bbox \
......
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
rectangularity
rectangularity_SOURCES = rectangularity.cc
TESTS = $(check_PROGRAMS)
// Copyright (C) 2009 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/// \file tests/accu/site_set/rectangularity.hh
///
/// Tests on mln::accu::site_set::rectangularity.
#include <mln/core/alias/point2d.hh>
#include <mln/core/alias/box2d.hh>
#include <mln/accu/site_set/rectangularity.hh>
int main()
{
using namespace mln;
{
accu::site_set::rectangularity<point2d> accu;
accu.take_as_init(point2d(0,0));
accu.take(point2d(0,1));
accu.take(point2d(1,0));
accu.take(point2d(1,1));
mln_assertion(accu.to_result() == 1);
}
{
accu::site_set::rectangularity<point2d> accu;
accu.take(point2d(0,0));
accu.take(point2d(1,1));
std::cout << accu << std::endl;
mln_assertion(accu.to_result() == 0.5f);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment