Commit 10172dec authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add new link filters.

	* scribo/filter/object_links_non_aligned_simple.hh: Handle new
	cases.

	* scribo/filter/object_links_left_aligned.hh,
	* scribo/filter/object_links_right_aligned.hh: New filters.
parent 3894a51d
2010-02-19 Guillaume Lazzara <z@lrde.epita.fr>
Add new link filters.
* scribo/filter/object_links_non_aligned_simple.hh: Handle new
cases.
* scribo/filter/object_links_left_aligned.hh,
* scribo/filter/object_links_right_aligned.hh: New filters.
2010-02-19 Guillaume Lazzara <z@lrde.epita.fr>
Improve object linking backend.
......
// 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_FILTER_OBJECT_LINKS_LEFT_ALIGNED_HH
# define SCRIBO_FILTER_OBJECT_LINKS_LEFT_ALIGNED_HH
/// \file
///
/// Invalidate links between two objects if their left are not
/// aligned.
///
/// \fixme UPDATE DOC!
# include <mln/util/array.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
# include <scribo/core/object_image.hh>
# include <scribo/filter/object_links_non_aligned_simple.hh>
namespace scribo
{
namespace filter
{
using namespace mln;
/*! \brief Invalidate links between two objects if their left are not
aligned.
\param[in] objects An object image.
\param[in] links Object links information.
\param[in] max_alpha Maximum angle value (degrees).
\verbatim
~
~ ^
~ |
~ |
~------ | Alpha
~ | | |
~ | | |
~ | | v
------ ~ ~ ~ | ~ ~| ~
| | | |
| x------------x |
| | | |
------ | |
object1 | |
------
object2
\endverbatim
The angle between the two lefts must be lower than \p max_alpha.
*/
template <typename L>
object_links<L>
object_links_left_aligned(const object_image(L)& objects,
const object_links<L>& links,
float max_alpha);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
object_links<L>
object_links_left_aligned(const object_image(L)& objects,
const object_links<L>& links,
float max_alpha)
{
trace::entering("scribo::filter::object_links_left_aligned");
mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
object_links<L>
output = object_links_non_aligned_simple(objects, links,
3,
max_alpha);
trace::exiting("scribo::filter::object_links_left_aligned");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::filter
} // end of namespace scribo
#endif // ! SCRIBO_FILTER_OBJECT_LINKS_LEFT_ALIGNED_HH
......@@ -84,6 +84,8 @@ namespace scribo
0 = center
1 = top
2 = bottom
3 = left
4 = right
*/
template <typename L>
......@@ -166,6 +168,40 @@ namespace scribo
}
}
}
// Left
else if (edge == 3)
{
for_all_components(i, objects.bboxes())
{
if (links[i] != i)
{
dr = math::abs(bboxes[i].center().row()
- bboxes[links[i]].center().row());
dc = math::abs(bboxes[i].pmin().col()
- bboxes[links[i]].pmin().col());
if (std::atan(dc / dr) > max_alpha_rad)
output[i] = i;
}
}
}
// Right
else if (edge == 4)
{
for_all_components(i, objects.bboxes())
{
if (links[i] != i)
{
dr = math::abs(bboxes[i].center().row()
- bboxes[links[i]].center().row());
dc = math::abs(bboxes[i].pmax().col()
- bboxes[links[i]].pmax().col());
if (std::atan(dc / dr) > max_alpha_rad)
output[i] = i;
}
}
}
else
{
trace::warning("Invalid edge value... Aborting computation.");
......
// 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_FILTER_OBJECT_LINKS_RIGHT_ALIGNED_HH
# define SCRIBO_FILTER_OBJECT_LINKS_RIGHT_ALIGNED_HH
/// \file
///
/// Invalidate links between two objects if their right are not
/// aligned.
# include <mln/util/array.hh>
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
# include <scribo/core/object_image.hh>
# include <scribo/filter/object_links_non_aligned_simple.hh>
namespace scribo
{
namespace filter
{
using namespace mln;
/*! \brief Invalidate links between two objects if their right are not
aligned.
\param[in] objects An object image.
\param[in] links Object links information.
\param[in] max_alpha Maximum angle value (degrees).
\verbatim
~
~ ^
~ |
~ |
~------ | Alpha
~ | | |
~ | | |
~ | | v
------ ~ ~ ~ | ~ ~| ~
| | | |
| x------------x |
| | | |
------ | |
object1 | |
------
object2
\endverbatim
The angle between the two rights must be lower than \p max_alpha.
*/
template <typename L>
object_links<L>
object_links_right_aligned(const object_image(L)& objects,
const object_links<L>& links,
float max_alpha);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
object_links<L>
object_links_right_aligned(const object_image(L)& objects,
const object_links<L>& links,
float max_alpha)
{
trace::entering("scribo::filter::object_links_right_aligned");
mln_precondition(objects.is_valid());
mln_precondition(links.is_valid());
object_links<L>
output = object_links_non_aligned_simple(objects, links,
4,
max_alpha);
trace::exiting("scribo::filter::object_links_right_aligned");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::filter
} // end of namespace scribo
#endif // ! SCRIBO_FILTER_OBJECT_LINKS_RIGHT_ALIGNED_HH
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