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

Add new routines to detect separators.

	* scribo/primitive/extract/horizontal_separators.hh,
	* scribo/primitive/extract/separators.hh,
	* scribo/primitive/extract/vertical_separators.hh,
	* scribo/primitive/remove/separators.hh: New.
parent 464d58f9
2010-04-30 Guillaume Lazzara <z@lrde.epita.fr>
Add new routines to detect separators.
* scribo/primitive/extract/horizontal_separators.hh,
* scribo/primitive/extract/separators.hh,
* scribo/primitive/extract/vertical_separators.hh,
* scribo/primitive/remove/separators.hh: New.
2010-04-30 Guillaume Lazzara <z@lrde.epita.fr>
Add A first draft of a README in Scribo.
......
// Copyright (C) 2010 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_EXTRACT_VERTICAL_SEPARATORS_HH
# define SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
/// \file
///
/// Extract vertical separators.
# include <mln/core/concept/image.hh>
# include <mln/arith/plus.hh>
# include <scribo/primitive/extract/lines_v_pattern.hh>
namespace scribo
{
namespace primitive
{
namespace extract
{
using namespace mln;
/// \brief Extract vertical separators.
/*!
*
* \param[in] input A binary image.
* \param[in] line_length The minimum line length.
*
* \return A binary image were separators are set to 'True'.
*
* \sa primitive::remove::separators
*/
template <typename I>
mln_concrete(I)
vertical_separators(const Image<I>& input, unsigned line_length);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_concrete(I)
vertical_separators(const Image<I>& input_, unsigned line_length)
{
trace::entering("scribo::primitive::extract::vertical_separators");
const I& input = exact(input_);
mlc_is(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
mln_concrete(I)
vlines = extract::lines_v_pattern(input, line_length, 3);
trace::exiting("scribo::primitive::extract::vertical_separators");
return vlines;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::primitive::extract
} // end of namespace scribo::primitive
} // end of namespace scribo
#endif // ! SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
// Copyright (C) 2010 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_EXTRACT_SEPARATORS_HH
# define SCRIBO_PRIMITIVE_EXTRACT_SEPARATORS_HH
/// \file
///
/// Extract vertical and horizontal separators.
# include <mln/core/concept/image.hh>
# include <mln/arith/plus.hh>
# include <scribo/primitive/extract/lines_h_pattern.hh>
# include <scribo/primitive/extract/lines_v_pattern.hh>
namespace scribo
{
namespace primitive
{
namespace extract
{
using namespace mln;
/// \brief Extract vertical and horizontal separators.
/*!
*
* \param[in] input A binary image.
* \param[in] line_length The minimum line length.
*
* \return A binary image were separators are set to 'True'.
*
* \sa primitive::remove::separators
*/
template <typename I>
mln_concrete(I)
separators(const Image<I>& input, unsigned line_length);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_concrete(I)
separators(const Image<I>& input_, unsigned line_length)
{
trace::entering("scribo::primitive::extract::separators");
const I& input = exact(input_);
mlc_is(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
mln_concrete(I)
hlines = extract::lines_h_pattern(input, line_length, 3),
vlines = extract::lines_v_pattern(input, line_length, 3);
hlines += vlines;
trace::exiting("scribo::primitive::extract::separators");
return hlines;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::primitive::extract
} // end of namespace scribo::primitive
} // end of namespace scribo
#endif // ! SCRIBO_PRIMITIVE_EXTRACT_SEPARATORS_HH
// Copyright (C) 2010 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_EXTRACT_VERTICAL_SEPARATORS_HH
# define SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
/// \file
///
/// Extract vertical separators.
# include <mln/core/concept/image.hh>
# include <mln/arith/plus.hh>
# include <scribo/primitive/extract/lines_v_pattern.hh>
namespace scribo
{
namespace primitive
{
namespace extract
{
using namespace mln;
/// \brief Extract vertical separators.
/*!
*
* \param[in] input A binary image.
* \param[in] line_length The minimum line length.
*
* \return A binary image were separators are set to 'True'.
*
* \sa primitive::remove::separators
*/
template <typename I>
mln_concrete(I)
vertical_separators(const Image<I>& input, unsigned line_length);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_concrete(I)
vertical_separators(const Image<I>& input_, unsigned line_length)
{
trace::entering("scribo::primitive::extract::vertical_separators");
const I& input = exact(input_);
mlc_is(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
mln_concrete(I)
vlines = extract::lines_v_pattern(input, line_length, 3);
trace::exiting("scribo::primitive::extract::vertical_separators");
return vlines;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::primitive::extract
} // end of namespace scribo::primitive
} // end of namespace scribo
#endif // ! SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
// Copyright (C) 2010 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_REMOVE_SEPARATORS_HH
# define SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_HH
/// \file
///
/// Remove separators in a binary image.
# include <mln/core/concept/image.hh>
# include <mln/core/routine/duplicate.hh>
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/pw/all.hh>
# include <mln/data/fill.hh>
namespace scribo
{
namespace primitive
{
namespace remove
{
using namespace mln;
/// \brief Remove separators in a binary image.
/*!
*
* \param[in] input A binary image. 'True' for objects, 'False'
* for the background.
* \param[in] separators A binary image of separators.
*
* \return \p input without separators.
*
* \sa primitive::extract::separators
*/
template <typename I>
mln_concrete(I)
separators(const Image<I>& input, const Image<I>& separators);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_concrete(I)
separators(const Image<I>& input_, const Image<I>& separators_)
{
trace::entering("scribo::primitive::remove::separators");
const I& input = exact(input_);
const I& separators = exact(separators_);
mlc_is(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
mln_precondition(separators.is_valid());
mln_concrete(I) output = duplicate(input);
data::fill((output | (pw::value(separators) == pw::cst(true))).rw(),
false);
trace::exiting("scribo::primitive::remove::separators");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::primitive::remove
} // end of namespace scribo::primitive
} // end of namespace scribo
#endif // ! SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_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