Commit 9ddb2ab5 authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Move height, volume, bbox accus in shape directory.


	* mln/accu/height.hh,
	* mln/accu/bbox.hh,
	* mln/accu/volume.hh: Move to...
	* mln/accu/shape,
	* mln/accu/shape/bbox.hh,
	* mln/accu/shape/height.hh,
	* mln/accu/shape/volume.hh:
	Move accus in shape directory.

	* tests/accu/bbox.cc: Move to...
	* tests/accu/shape,
	* tests/accu/shape/bbox.cc:
	Move tests in shape directory.

	* tests/accu/Makefile.am,
	* tests/accu/shape/Makefile.am:
	Update makefiles respecting new locations.

	* mln/accu/median_alt.hh: Move to...
	* mln/accu/stat/median_alt.hh:
	Move median_alt (no more used anywhere...) in stat directory.

	* mln/accu/all.hh,
	* mln/accu/essential.hh,
	* mln/accu/shape/all.hh,
	* mln/accu/shape/essential.hh
	* mln/accu/stat/all.hh:
	Update all.hh and essential.hh respecting new locations.

	* doc/examples/labeling-compute.cc,
	* doc/examples/split/labeling-compute-3.cc,
	* mln/accu/site_set/rectangularity.hh,
	* mln/accu/center.hh,
	* mln/core/image/dmorph/p2p_image.hh,
	* mln/core/image/imorph/labeled_image.hh,
	* mln/core/internal/geom_bbox.hh,
	* mln/core/internal/site_set_impl.hh,
	* mln/geom/bbox.hh,
	* sandbox/abraham/mln/core/site_set/p_priority_queue.hh,
	* sandbox/duhamel/mesh_p.hh,
	* sandbox/duhamel/queue_p_fast.hh,
	* sandbox/duhamel/queue_p_priority.hh,
	* sandbox/fred/old/p2p/p2p_morpher.hh,
	* sandbox/fred/old/value.cc,
	* sandbox/garrigues/factures/extract_array.cc,
	* sandbox/garrigues/factures/extract_array_highlight.cc,
	* sandbox/garrigues/fllt/essai.cc,
	* sandbox/garrigues/fllt/fllt_simple.cc,
	* sandbox/garrigues/fllt/fllt_simple.svg.1.cc,
	* sandbox/garrigues/fllt/fllt_simple.svg.2.cc,
	* sandbox/garrigues/fllt/fllt_simple.svg.3.cc,
	* sandbox/garrigues/fllt/fllt_theo.cc,
	* sandbox/garrigues/fllt/types.hh,
	* sandbox/icdar/2009/hsc/clean_input.hh,
	* sandbox/icdar/2009/hsc/clean_lines.hh,
	* sandbox/icdar/2009/hsc/clean_lines_with_grouped_bboxes.hh,
	* sandbox/icdar/2009/hsc/get_line_images.hh,
	* sandbox/icdar/2009/hsc/lines_to_boxes.cc,
	* sandbox/inim/2010/boxes/boxes.cc,
	* sandbox/inim/2010/rag/center_weight.hh,
	* sandbox/jardonnet/n_cmpt/n_cmpt.cc,
	* sandbox/jardonnet/n_cmpt/n_cmpt.hh,
	* sandbox/jardonnet/n_cmpt/n_cmpt2.hh,
	* sandbox/jardonnet/n_cmpt/n_cmpt3.hh,
	* sandbox/jardonnet/n_cmpt/n_cmpt4.hh,
	* sandbox/jardonnet/n_cmpt/n_cmpt5.hh,
	* sandbox/jardonnet/n_cmpt/nwst.hh,
	* sandbox/jardonnet/n_cmpt/test_attribute_watershed.cc,
	* sandbox/jardonnet/n_cmpt/tikz.hh,
	* sandbox/laurent/ismm2009.cc,
	* sandbox/nivault/extract_character.cc,
	* sandbox/nivault/extract_score.cc,
	* sandbox/pellegrin/set/core/internal/multi_set.hh,
	* sandbox/pellegrin/set/core/internal/uni_set.hh,
	* sandbox/pellegrin/set/core/p_array.hh,
	* sandbox/pellegrin/set/core/p_bgraph.hh,
	* sandbox/pellegrin/set/core/p_graph.hh,
	* sandbox/pellegrin/set/core/p_line_graph.hh,
	* sandbox/pellegrin/set/core/p_priority_queue.hh,
	* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
	* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
	* sandbox/pellegrin/set/core/p_queue.hh,
	* sandbox/pellegrin/set/core/p_queue_fast.hh,
	* sandbox/pellegrin/set/core/p_run.hh,
	* sandbox/pellegrin/set/core/p_runs.hh,
	* sandbox/pellegrin/set/core/p_set.hh,
	* sandbox/theo/color/blen_pix.hh,
	* sandbox/theo/color/filter_blen_rgb_edges.cc,
	* sandbox/theo/color/segment_gl_pixels.cc,
	* sandbox/theo/color/segment_rgb_edges.cc,
	* sandbox/theo/esiee/laurent/ismm09/trash.hh,
	* sandbox/theo/fllt.svg.6.cc,
	* sandbox/theo/fllt.svg.7.hh,
	* sandbox/theo/fllt/fllt.hh,
	* sandbox/theo/fllt/fllt.svg.1.cc,
	* sandbox/theo/fllt/fllt.svg.2.cc,
	* sandbox/theo/fllt/fllt.svg.3.cc,
	* sandbox/theo/fllt/fllt.svg.4.cc,
	* sandbox/theo/fllt/fllt.svg.5.cc,
	* sandbox/theo/fllt/fllt.svg.6.cc,
	* sandbox/theo/fllt/fllt.svg.7.hh,
	* sandbox/theo/fllt/fllt_test.hh,
	* sandbox/theo/p_runs__with_dedicated_piter.hh,
	* sandbox/theo/tufa_2008/experiment.cc,
	* sandbox/theo/tufa_2008/filter.cc,
	* sandbox/theo/tufa_2008/n_cmpt.cc,
	* sandbox/theo/tufa_2008/wst_f_equal_wst_a.cc,
	* tests/accu/all_accus.cc,
	* tests/core/image/edge_image.cc,
	* tests/core/image/graph_image.cc,
	* tests/core/image/imorph/labeled_image.cc,
	* tests/core/image/vertex_image.cc,
	* tests/morpho/closing/leveling.cc,
	* tests/morpho/graph_image_morpho.cc,
	* tests/morpho/opening/leveling.cc,
	* trash/obased_rle_image.hh,
	* trash/p_bgraph.hh:
	Replace accu::accu_name by accu::shape::accu_name,
		accu::meta::accu_name by accu::meta::shape::accu_name,
		accu/accu_name by accu/shape/accu_name.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4120 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 51e54a96
2009-06-12 Edwin Carlinet <carlinet@lrde.epita.fr>
Move height, volume, bbox accus in shape directory.
* mln/accu/height.hh,
* mln/accu/bbox.hh,
* mln/accu/volume.hh: Move to...
* mln/accu/shape,
* mln/accu/shape/bbox.hh,
* mln/accu/shape/height.hh,
* mln/accu/shape/volume.hh:
Move accus in shape directory.
* tests/accu/bbox.cc: Move to...
* tests/accu/shape,
* tests/accu/shape/bbox.cc:
Move tests in shape directory.
* tests/accu/Makefile.am,
* tests/accu/shape/Makefile.am:
Update makefiles respecting new locations.
* mln/accu/median_alt.hh: Move to...
* mln/accu/stat/median_alt.hh:
Move median_alt (no more used anywhere...) in stat directory.
* mln/accu/all.hh,
* mln/accu/essential.hh,
* mln/accu/shape/all.hh,
* mln/accu/shape/essential.hh
* mln/accu/stat/all.hh:
Update all.hh and essential.hh respecting new locations.
* doc/examples/labeling-compute.cc,
* doc/examples/split/labeling-compute-3.cc,
* mln/accu/site_set/rectangularity.hh,
* mln/accu/center.hh,
* mln/core/image/dmorph/p2p_image.hh,
* mln/core/image/imorph/labeled_image.hh,
* mln/core/internal/geom_bbox.hh,
* mln/core/internal/site_set_impl.hh,
* mln/geom/bbox.hh,
* sandbox/abraham/mln/core/site_set/p_priority_queue.hh,
* sandbox/duhamel/mesh_p.hh,
* sandbox/duhamel/queue_p_fast.hh,
* sandbox/duhamel/queue_p_priority.hh,
* sandbox/fred/old/p2p/p2p_morpher.hh,
* sandbox/fred/old/value.cc,
* sandbox/garrigues/factures/extract_array.cc,
* sandbox/garrigues/factures/extract_array_highlight.cc,
* sandbox/garrigues/fllt/essai.cc,
* sandbox/garrigues/fllt/fllt_simple.cc,
* sandbox/garrigues/fllt/fllt_simple.svg.1.cc,
* sandbox/garrigues/fllt/fllt_simple.svg.2.cc,
* sandbox/garrigues/fllt/fllt_simple.svg.3.cc,
* sandbox/garrigues/fllt/fllt_theo.cc,
* sandbox/garrigues/fllt/types.hh,
* sandbox/icdar/2009/hsc/clean_input.hh,
* sandbox/icdar/2009/hsc/clean_lines.hh,
* sandbox/icdar/2009/hsc/clean_lines_with_grouped_bboxes.hh,
* sandbox/icdar/2009/hsc/get_line_images.hh,
* sandbox/icdar/2009/hsc/lines_to_boxes.cc,
* sandbox/inim/2010/boxes/boxes.cc,
* sandbox/inim/2010/rag/center_weight.hh,
* sandbox/jardonnet/n_cmpt/n_cmpt.cc,
* sandbox/jardonnet/n_cmpt/n_cmpt.hh,
* sandbox/jardonnet/n_cmpt/n_cmpt2.hh,
* sandbox/jardonnet/n_cmpt/n_cmpt3.hh,
* sandbox/jardonnet/n_cmpt/n_cmpt4.hh,
* sandbox/jardonnet/n_cmpt/n_cmpt5.hh,
* sandbox/jardonnet/n_cmpt/nwst.hh,
* sandbox/jardonnet/n_cmpt/test_attribute_watershed.cc,
* sandbox/jardonnet/n_cmpt/tikz.hh,
* sandbox/laurent/ismm2009.cc,
* sandbox/nivault/extract_character.cc,
* sandbox/nivault/extract_score.cc,
* sandbox/pellegrin/set/core/internal/multi_set.hh,
* sandbox/pellegrin/set/core/internal/uni_set.hh,
* sandbox/pellegrin/set/core/p_array.hh,
* sandbox/pellegrin/set/core/p_bgraph.hh,
* sandbox/pellegrin/set/core/p_graph.hh,
* sandbox/pellegrin/set/core/p_line_graph.hh,
* sandbox/pellegrin/set/core/p_priority_queue.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
* sandbox/pellegrin/set/core/p_queue.hh,
* sandbox/pellegrin/set/core/p_queue_fast.hh,
* sandbox/pellegrin/set/core/p_run.hh,
* sandbox/pellegrin/set/core/p_runs.hh,
* sandbox/pellegrin/set/core/p_set.hh,
* sandbox/theo/color/blen_pix.hh,
* sandbox/theo/color/filter_blen_rgb_edges.cc,
* sandbox/theo/color/segment_gl_pixels.cc,
* sandbox/theo/color/segment_rgb_edges.cc,
* sandbox/theo/esiee/laurent/ismm09/trash.hh,
* sandbox/theo/fllt.svg.6.cc,
* sandbox/theo/fllt.svg.7.hh,
* sandbox/theo/fllt/fllt.hh,
* sandbox/theo/fllt/fllt.svg.1.cc,
* sandbox/theo/fllt/fllt.svg.2.cc,
* sandbox/theo/fllt/fllt.svg.3.cc,
* sandbox/theo/fllt/fllt.svg.4.cc,
* sandbox/theo/fllt/fllt.svg.5.cc,
* sandbox/theo/fllt/fllt.svg.6.cc,
* sandbox/theo/fllt/fllt.svg.7.hh,
* sandbox/theo/fllt/fllt_test.hh,
* sandbox/theo/p_runs__with_dedicated_piter.hh,
* sandbox/theo/tufa_2008/experiment.cc,
* sandbox/theo/tufa_2008/filter.cc,
* sandbox/theo/tufa_2008/n_cmpt.cc,
* sandbox/theo/tufa_2008/wst_f_equal_wst_a.cc,
* tests/accu/all_accus.cc,
* tests/core/image/edge_image.cc,
* tests/core/image/graph_image.cc,
* tests/core/image/imorph/labeled_image.cc,
* tests/core/image/vertex_image.cc,
* tests/morpho/closing/leveling.cc,
* tests/morpho/graph_image_morpho.cc,
* tests/morpho/opening/leveling.cc,
* trash/obased_rle_image.hh,
* trash/p_bgraph.hh:
Replace accu::accu_name by accu::shape::accu_name,
accu::meta::accu_name by accu::meta::shape::accu_name,
accu/accu_name by accu/shape/accu_name.
2009-06-11 Roland Levillain <roland@lrde.epita.fr>
 
Help the compiler find mln::math::max in mln::accu::label_used.
......@@ -9,7 +9,7 @@
#include <mln/util/array.hh>
#include <mln/accu/bbox.hh>
#include <mln/accu/shape/bbox.hh>
#include <mln/value/label_8.hh>
......@@ -45,7 +45,7 @@ int main()
// \{
util::array<box2d> boxes =
labeling::compute(accu::meta::bbox(),
labeling::compute(accu::meta::shape::bbox(),
lbl,
nlabels);
// \}
......
util::array<box2d> boxes =
labeling::compute(accu::meta::bbox(),
labeling::compute(accu::meta::shape::bbox(),
lbl,
nlabels);
......@@ -53,11 +53,9 @@ namespace mln
}
# include <mln/accu/bbox.hh>
# include <mln/accu/count_labels.hh>
# include <mln/accu/center.hh>
// << # include <mln/accu/count_adjacent_vertices.hh> >>
# include <mln/accu/height.hh>
# include <mln/accu/histo.hh>
# include <mln/accu/label_used.hh>
# include <mln/accu/line.hh>
......@@ -66,7 +64,6 @@ namespace mln
# include <mln/accu/rank.hh>
# include <mln/accu/rms.hh>
// << # include <mln/accu/tuple.hh> >>
# include <mln/accu/volume.hh>
// Routines.
......@@ -85,6 +82,7 @@ namespace mln
# include <mln/accu/site_set/all.hh>
# include <mln/accu/stat/all.hh>
# include <mln/accu/logic/all.hh>
# include <mln/accu/math/all.hh>
# include <mln/accu/shape/all.hh>
#endif // ! MLN_ACCU_ALL_HH
......@@ -33,7 +33,7 @@
/// \todo Fix to_result() value when invalid...
# include <mln/accu/internal/base.hh>
# include <mln/accu/bbox.hh>
# include <mln/accu/shape/bbox.hh>
namespace mln
{
......
......@@ -30,7 +30,6 @@
///
/// File that includes the most useful accumulator types.
# include <mln/accu/bbox.hh>
# include <mln/accu/center.hh>
# include <mln/accu/histo.hh>
# include <mln/accu/rank.hh>
......@@ -38,5 +37,7 @@
# include <mln/accu/stat/essential.hh>
# include <mln/accu/image/essential.hh>
# include <mln/accu/site_set/essential.hh>
# include <mln/accu/shape/essential.hh>
# include <mln/accu/math/essential.hh>
#endif // ! MLN_ACCU_ESSENTIAL_HH
// Copyright (C) 2007, 2008, 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 MLN_ACCU_MEDIAN_ALT_HH
# define MLN_ACCU_MEDIAN_ALT_HH
/// \file
///
/// Define alternative generic median accumulator class.
# include <mln/accu/internal/base.hh>
# include <mln/accu/histo.hh>
namespace mln
{
namespace accu
{
/// \brief Generic median_alt function based on histogram over a
/// value set with type \c S.
///
/// \ingroup modaccuvalues
//
template <typename S>
struct median_alt : public mln::accu::internal::base< const mln_value(S)&, median_alt<S> >
{
typedef mln_value(S) argument;
median_alt(const Value_Set<S>& s);
/// Manipulators.
/// \{
void take(const argument& t);
void untake(const argument& t);
void init();
/// \}
/// Get the value of the accumulator.
const argument& to_result() const;
/// Check whether this accu is able to return a result.
/// Always true here.
bool is_valid() const;
// FIXME: remove
void debug__() const
{
std::cout << " i = " << i_
<< " t = " << t_
<< " s = " << sum_minus_ << " ; " << h_[i_] << " ; " << sum_plus_ << " = " << h_.sum()
<< std::endl;
}
protected:
histo<S> h_;
/// derived from h_
const S& s_;
unsigned sum_minus_, sum_plus_;
/// the median index
unsigned i_;
/// the median argument
argument t_;
// Auxiliary methods
void go_minus_();
void go_plus_();
};
namespace meta
{
/// Meta accumulator for median_alt.
template <typename T>
struct median_alt : public Meta_Accumulator< median_alt<T> >
{
median_alt(const Value_Set<T>& s_) : s(s_) {}
struct with
{
typedef accu::median_alt<T> ret;
};
Value_Set<T> s;
};
} // end of namespace mln::accu::meta
template <typename T>
median_alt<T> unmeta(const meta::median_alt<T>& m, T)
{
median_alt<T> a(m.s);
return a;
}
template <typename T>
struct median_alt_on : public median_alt< value::set<T> >
{
median_alt_on()
: median_alt< value::set<T> >(value::set<T>::the())
{
}
};
# ifndef MLN_INCLUDE_ONLY
template <typename S>
inline
median_alt<S>::median_alt(const Value_Set<S>& s)
: h_(s),
s_(h_.vset())
{
init();
}
template <typename S>
inline
void
median_alt<S>::take(const argument& t)
{
// update h_
h_.take(t);
// particular case:
// current state was initialization
if (h_[i_] == 0)
{
// std::cout << "init!" << std::endl;
i_ = s_.index_of(t);
t_ = t;
return;
}
// particular case:
// the median does not change
if (t == t_)
{
// std::cout << "no change!" << std::endl;
return;
}
// general case:
if (t < t_)
{
++sum_minus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
// t > t_
{
++sum_plus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
}
template <typename S>
inline
void
median_alt<S>::untake(const argument& t)
{
mln_precondition(h_(t) != 0);
// update h_
h_.untake(t);
// particular case:
// the only value has been removed
if (h_.sum() == 0)
{
init();
return;
}
// general case:
if (t < t_)
{
--sum_minus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
else if (t > t_)
{
--sum_plus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
// t == t_
{
if (h_[i_] == 0)
{
// go to the heaviest side
if (sum_plus_ > sum_minus_)
go_plus_();
else
go_minus_(); // default when both sides are balanced
}
else
{
if (2 * sum_plus_ > h_.sum())
go_plus_();
else if (2 * sum_minus_ > h_.sum())
go_minus_();
// else no change
}
}
}
template <typename S>
inline
void
median_alt<S>::init()
{
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(argument) - mln_min(argument)) / 2;
t_ = s_[i_];
}
template <typename S>
inline
const typename median_alt<S>::argument&
median_alt<S>::to_result() const
{
return t_;
}
template <typename S>
inline
bool
median_alt<S>::is_valid() const
{
return true;
}
template <typename S>
inline
void
median_alt<S>::go_minus_()
{
do
{
sum_plus_ += h_[i_];
do
--i_;
while (h_[i_] == 0);
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
t_ = s_[i_];
}
template <typename S>
inline
void
median_alt<S>::go_plus_()
{
do
{
sum_minus_ += h_[i_];
do
++i_;
while (h_[i_] == 0);
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
t_ = s_[i_];
}
template <typename S>
inline
std::ostream& operator<<(std::ostream& ostr, const median_alt<S>& m)
{
m.debug__();
return ostr << m.to_result();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
} // end of namespace mln
#endif // ! MLN_ACCU_MEDIAN_ALT_HH
// 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 MLN_ACCU_SHAPE_ALL_HH
# define MLN_ACCU_SHAPE_ALL_HH
/// \file
///
/// File that includes all shape accumulator types.
namespace mln
{
namespace accu
{
namespace meta
{
/// Namespace of shape meta-accumulators.
namespace shape {}
} // end of namespace mln::accu::meta
/// Namespace of shape accumulators.
namespace shape {}
} // end of namespace mln::accu
} // end of namespace mln
# include <mln/accu/shape/volume.hh>
# include <mln/accu/shape/height.hh>
# include <mln/accu/shape/bbox.hh>
#endif // ! MLN_ACCU_SHAPE_ALL_HH
......@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef MLN_ACCU_BBOX_HH
# define MLN_ACCU_BBOX_HH
#ifndef MLN_ACCU_SHAPE_BBOX_HH
# define MLN_ACCU_SHAPE_BBOX_HH
/// \file
///
......@@ -41,181 +41,196 @@ namespace mln
namespace accu
{
/// \brief Generic bounding box accumulator class.
///
/// The parameter \c P is the type of points.
///
/// \ingroup modaccusiteset
//
template <typename P>
struct bbox : public mln::accu::internal::base< const box<P>& , bbox<P> >
namespace shape
{
typedef P argument;
bbox();
/// Manipulators.
/// \{
void init();
void take_as_init_(const P& p);
void take(const P& p);
void take(const bbox<P>& other);
void take(const box<P>& b);
/// \}
/// \brief Generic bounding box accumulator class.
///
/// The parameter \c P is the type of points.