Commit 52112930 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Remove deprecated files.

	* core/internal/link_functor_base.hh,
	* debug/save_object_diff.hh,
	* make/text.hh,
	* primitive/internal/update_link_array.hh,
	* primitive/link/internal/anchors_3.hh,
	* primitive/link/internal/link_ms_dmax_base.hh,
	* primitive/link/internal/link_ms_dmax_ratio_base.hh,
	* src/pbm_lines_in_doc.cc: Remove.
parent c3c62f22
2010-08-09 Guillaume Lazzara <z@lrde.epita.fr>
Remove deprecated files.
* core/internal/link_functor_base.hh,
* debug/save_object_diff.hh,
* make/text.hh,
* primitive/internal/update_link_array.hh,
* primitive/link/internal/anchors_3.hh,
* primitive/link/internal/link_ms_dmax_base.hh,
* primitive/link/internal/link_ms_dmax_ratio_base.hh,
* src/pbm_lines_in_doc.cc: Remove.
2010-08-09 Guillaume Lazzara <z@lrde.epita.fr>
Fix many tests in Scribo.
......
// 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_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
# define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_HH
/// \file
///
/// Base class for link functors.
# include <mln/core/concept/image.hh>
# include <mln/math/abs.hh>
# include <mln/util/array.hh>
# include <mln/util/couple.hh>
# include <scribo/core/concept/link_functor.hh>
# include <scribo/core/object_image.hh>
# include <scribo/core/object_links.hh>
# include <scribo/primitive/internal/init_link_array.hh>
namespace scribo
{
namespace internal
{
/// \brief Base class for link functors.
template <typename L, typename E>
class link_functor_base : public Link_Functor<E>
{
public:
typedef L support;
link_functor_base(const object_image(L)& objects);
const object_links<L>& links() const;
unsigned link(unsigned object) const;
const object_image(L)& objects() const;
protected:
object_links<L> links_;
const object_image(L) objects_;
};
# ifndef MLN_INCLUDE_ONLY
template <typename L, typename E>
inline
link_functor_base<L,E>::link_functor_base(const object_image(L)& objects)
: links_(objects, static_cast<unsigned>(objects.nlabels()) + 1),
objects_(objects)
{
primitive::internal::init_link_array(links_);
}
template <typename L, typename E>
inline
const object_links<L>&
link_functor_base<L,E>::links() const
{
return links_;
}
template <typename L, typename E>
inline
unsigned
link_functor_base<L,E>::link(unsigned object) const
{
return links_[object];
}
template <typename L, typename E>
inline
const object_image(L)&
link_functor_base<L,E>::objects() const
{
return objects_;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::internal
} // end of namespace scribo
#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_FUNCTOR_BASE_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 SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
# define SCRIBO_DEBUG_SAVE_OBJECT_DIFF_HH
/// \file
///
/// Show the difference between two object images.
# include <mln/core/image/image2d.hh>
# include <mln/core/concept/image.hh>
# include <mln/data/fill.hh>
# include <mln/labeling/colorize.hh>
# include <mln/value/rgb8.hh>
# include <mln/io/ppm/save.hh>
# include <mln/literal/black.hh>
# include <mln/literal/colors.hh>
# include <mln/pw/all.hh>
# include <mln/core/image/dmorph/image_if.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_image.hh>
namespace scribo
{
namespace debug
{
using namespace mln;
/*! \brief Show the difference between two object images.
\param[in] lbl An object image.
\param[in] lbl_2 Another object image.
\param[in] filename The output filename.
*/
template <typename L, typename L2>
void
save_object_diff(const object_image(L)& lbl, const object_image(L2)& lbl_2,
const std::string& filename);
# ifndef MLN_INCLUDE_ONLY
template <typename L, typename L2>
void
save_object_diff(const object_image(L)& lbl, const object_image(L2)& lbl_2,
const std::string& filename)
{
image2d<value::rgb8> output;
initialize(output, lbl_2);
data::fill(output, literal::black);
for_all_components(i, lbl.bboxes())
data::fill(((output | lbl.bbox(i)).rw() | (pw::value(lbl) == i)).rw(), literal::red);
for_all_components(i, lbl_2.bboxes())
data::fill(((output | lbl_2.bbox(i)).rw() | (pw::value(lbl_2) == i)).rw(), literal::green);
io::ppm::save(output, filename);
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::debug
} // end of namespace scribo
#endif // ! SCRIBO_DEBUG_SAVE_OBJECT_DIFF_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 SCRIBO_MAKE_TEXT_HH
# define SCRIBO_MAKE_TEXT_HH
/// \file
///
/// Construct a util::text.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/site_set/box.hh>
# include <mln/fun/i2v/array.hh>
# include <mln/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
# include <mln/labeling/relabel.hh>
# include <mln/util/array.hh>
# include <mln/make/relabelfun.hh>
# include <scribo/core/macros.hh>
# include <scribo/util/text.hh>
namespace scribo
{
namespace make
{
/// Construct a util::text
///
/// \param[in] bboxes Text component bounding boxes.
/// \param[in] lbl Associated label image.
/// \param[in] nbboxes The number of bounding boxes.
///
/// \return A util::text.
template <typename L>
scribo::util::text<L>
text(const mln::util::array<box<mln_site(L)> >& bboxes,
const Image<L>& lbl,
mln_value(L)& nbboxes);
/// Construct a util::text
///
/// \param[in] input_ A binary image.
/// \param[in] nbh_ A neighborhood to be used with labeling algorithms.
/// \param[in] nbboxes The number of bounding boxes.
///
/// \return A util::text.
template <typename I, typename N, typename V>
scribo::util::text<mln_ch_value(I,V)>
text(const Image<I>& input_, const Neighborhood<N>& nbh_,
V& nbboxes);
/// Construct a new util::text from another one.
///
/// \param[in] text A text structure.
/// \param[in] f_ A function v2v or v2b. It will be used to regroup text
/// components.
///
/// \return a new util::text.
//
template <typename L, typename F>
scribo::util::text<L>
text(const scribo::util::text<L>& text,
const Function<F>& f_);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
scribo::util::text<L>
text(const mln::util::array<box<mln_site(L)> >& bboxes,
const Image<L>& lbl,
mln_value(L)& nbboxes)
{
trace::entering("scribo::make::text");
mln_precondition(exact(lbl).is_valid());
scribo::util::text<L> result = scribo::util::text<L>(bboxes, lbl,
nbboxes);
trace::exiting("scribo::make::text");
return result;
}
template <typename I, typename N, typename V>
scribo::util::text<mln_ch_value(I,V)>
text(const Image<I>& input_, const Neighborhood<N>& nbh_,
V& nbboxes)
{
trace::entering("scribo::make::text");
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
typedef mln::util::array< box<mln_site(I)> > boxes_t;
mln_ch_value(I,V) lbl = labeling::blobs(input, nbh, nbboxes);
boxes_t cboxes = labeling::compute(accu::meta::shape::bbox(), lbl, nbboxes);
trace::exiting("scribo::make::text");
return make::text(cboxes, lbl, nbboxes);
}
template <typename L, typename F>
scribo::util::text<L>
text(const scribo::util::text<L>& text,
const Function<F>& f_)
{
trace::entering("scribo::make::text");
mln_precondition(text.is_valid());
const F& f = exact(f_);
mln_value(L) new_nbboxes;
mln::fun::i2v::array<mln_value(L)> fv2v
= mln::make::relabelfun(f, text.nbboxes(), new_nbboxes);
L lbl = labeling::relabel(text.label_image(), text.nbboxes(), fv2v);
mln::util::array< accu::shape::bbox<mln_site(L)> > tboxes(new_nbboxes.next());
mln::util::array< accu::center<mln_site(L)> > tcenters(new_nbboxes.next());
for_all_comps(i, text.bboxes())
{
tboxes[fv2v(i)].take(text.bbox(i));
tcenters[fv2v(i)].take(text.mass_center(i));
}
scribo::util::text<L> new_text;
new_text.nbboxes() = new_nbboxes;
new_text.label_image() = lbl;
convert::from_to(tboxes, new_text.bboxes());
convert::from_to(tcenters, new_text.mass_centers());
trace::exiting("scribo::make::text");
return new_text;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::make
} // end of namespace scribo
#endif // ! SCRIBO_MAKE_TEXT_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 SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
# define SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_HH
/// \file
///
/// Update a lookup table if a neighbor is found on the right of
/// the current bbox.
///
/// \todo To be deleted.
# include <mln/core/concept/image.hh>
# include <mln/util/array.hh>
# include <mln/math/abs.hh>
namespace scribo
{
namespace primitive
{
namespace internal
{
using namespace mln;
/// Update the lookup table \p link_array if a neighbor is found
/// on the right of the current bbox.
///
/// \param[in] lbl A label image.
/// \param[in] link_array Links of bounding boxes.
/// \param[in] p A site of \p lbl.
/// \param[in] c A site of \p lbl.
//
template <typename I>
bool
update_link_array(const Image<I>& lbl,
mln::util::array<unsigned>& link_array,
const mln_site(I)& p, const mln_site(I)& c,
unsigned i, float dmax);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
bool
update_link_array(const Image<I>& lbl_,
mln::util::array<unsigned>& link_array,
const mln_site(I)& p, const mln_site(I)& c,
unsigned i, float dmax)
{
const I& lbl = exact(lbl_);
mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
mln_assertion(lbl.is_valid());
if (lbl.domain().has(p) // Not outside image domain
&& lbl(p) != literal::zero // Not the background
&& lbl(p) != i // Not the current component
&& static_cast<float>((math::abs(p.col() - c.col()))) < dmax // Not too far
&& link_array[lbl(p)] != i) // Not creating a loop
{
link_array[i] = lbl(p);
return true;
}
return false;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::primitive::internal
} // end of namespace scribo::text
} // end of namespace scribo
#endif // ! SCRIBO_PRIMITIVE_INTERNAL_UPDATE_LINK_ARRAY_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 SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
# define SCRIBO_PRIMITIVE_LINK_INTERNAL_ANCHORS_3_HH
/// \file
///
/// Routine providing 3 anchors for neighbor seeking.
# include <mln/math/min.hh>
# include <mln/util/array.hh>
# include <scribo/core/object_image.hh>
namespace scribo
{
namespace primitive
{
namespace link
{
namespace internal
{
/*! \brief Return the proper anchor used to find a neighbor.
This routine provides up to 3 different anchors.
\param[in] objects An object image.
\param[in] mass_centers Object mass centers.
\param[in] current_object An object id.
\param[in] anchor The expected anchor.
Anchor can take one of the following values:
- 0, top anchor.
- 1, center anchor. It is the mass center.
- 2, bottom anchor.
Top and bottom anchors are respectively computed from the
bbox pmin and the bbox pmax, P.
Then the output anchor coordinates are computed as follows:
out.col = bbox.center.col
if object height, h, is lower than 30.
out.row = P.row + min(2, (h + 1) / 2 - 1)
else
out.row = P.row - min(10, h /10)
*/
template <typename L, typename P>
mln_site(L)
anchors_3(const object_image(L)& objects,
const mln::util::array<P>& mass_centers,
unsigned current_object, unsigned anchor);
# ifndef MLN_INCLUDE_ONLY
template <typename L, typename P>
mln_site(L)
anchors_3(const object_image(L)& objects,
const mln::util::array<P>& mass_centers,
unsigned current_object, unsigned anchor)
{
unsigned h = objects.bbox(current_object).pmax().row()
- objects.bbox(current_object).pmin().row();
mln_site(L) sp = objects.bbox(current_object).center();
mln::def::coord r;
switch (anchor)