4481: estim/object_groups_v_thickness.hh: New routine. Estimate object group thickness.

--- scribo/ChangeLog | 5 ++ scribo/estim/object_groups_v_thickness.hh | 102 +++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 0 deletions(-) create mode 100644 scribo/estim/object_groups_v_thickness.hh diff --git a/scribo/ChangeLog b/scribo/ChangeLog index e8bbe11..53bec20 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,8 @@ +2009-09-15 Guillaume Lazzara <lazzara@lrde.epita.fr> + + * estim/object_groups_v_thickness.hh: New routine. Estimate + object group thickness. + 2009-08-31 Guillaume Lazzara <lazzara@lrde.epita.fr> Fix compilation issues in Scribo. diff --git a/scribo/estim/object_groups_v_thickness.hh b/scribo/estim/object_groups_v_thickness.hh new file mode 100644 index 0000000..6453a1a --- /dev/null +++ b/scribo/estim/object_groups_v_thickness.hh @@ -0,0 +1,102 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project 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 SCRIBO_ESTIM_OBJECT_GROUPS_V_THICKNESS_HH +# define SCRIBO_ESTIM_OBJECT_GROUPS_V_THICKNESS_HH + + +/// \file +/// +/// \brief Estimate the mean object thickness for each group. + + +# include <mln/util/array.hh> +# include <scribo/core/object_groups.hh> +# include <scribo/core/macros.hh> + + +namespace scribo +{ + + namespace estim + { + + using namespace mln; + + /*! \brief Estimate the mean object thickness for each group. + + \param[in] groups Object groups information. + + \return An array of mean object thickness. + + */ + template <typename L> + mln::util::array<float> + object_groups_v_thickness(const object_groups<L>& groups); + + + +# ifndef MLN_INCLUDE_ONLY + + + template <typename L> + util::array<float> + object_groups_v_thickness(const object_groups<L>& groups) + { + trace::entering("scribo::estim::object_groups_v_thickness"); + + mln_precondition(groups.is_valid()); + + const object_image(L)& objects = groups.object_image_(); + + //FIXME: remove when object_groups will store the number of + //elements per group. + mln::util::array<unsigned> group_card(groups.size(), 0.0); + + mln::util::array<float> output(groups.size(), 0.0); + for_all_components(i, objects.bboxes()) + { + output[groups[i]] += objects.bbox(i).pmax().row() + - objects.bbox(i).pmin().row(); + ++group_card[groups[i]]; + } + + output(0) = 0; + for_all_components(i, output) + output(i) /= static_cast<float>(group_card[i]); + + trace::exiting("scribo::estim::object_groups_v_thickness"); + return output; + } + + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace scribo::estim + +} // end of namespace scribo + +#endif // ! SCRIBO_ESTIM_OBJECT_GROUPS_V_THICKNESS_HH -- 1.5.6.5
participants (1)
-
Guillaume Lazzara