$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
scribo::component_set< L > Class Template Reference

#include <scribo/core/component_set.hh>

Public Types

typedef Object< void > category
typedef component_set< L > exact_t

Public Member Functions

 component_set ()
 component_set (const mln::util::tracked_ptr< data_t > &data)
 component_set (const L &ima, const typename L::value &ncomps)
 component_set (const L &ima, const typename L::value &ncomps, const mln::util::array< pair_accu_t > &attribs, component::Type type=component::Undefined)
 component_set (const L &ima, const typename L::value &ncomps, const mln::util::array< pair_data_t > &attribs, component::Type type=component::Undefined)
void accept (const SerializeVisitor< E2 > &visitor) const
void add_separators (const typename mln::trait::ch_value< L, bool >::ret &ima)
void clear_separators ()
component_set< L > duplicate () const
bool has_separators () const
const component_info< L > & info (const typename L::value &id) const
component_info< L > & info (const typename L::value &id)
bool is_valid () const
const L & labeled_image () const
L::value nelements () const
component_info< L > & operator() (const component_id_t &id)
const component_info< L > & operator() (const component_id_t &id) const
const mln::trait::ch_value< L,
bool >::ret
separators () const
template<typename F >
void update_tags (const mln::Function_v2b< F > &f, component::Tag tag)

Protected Member Functions

void init_ (const component_set< L > &model)

Protected Attributes

mln::util::tracked_ptr< data_tdata_

Related Functions

(Note that these are not member functions.)

template<typename L >
std::ostream & operator<< (std::ostream &ostr, const component_set< L > &info)
template<typename L >
bool operator== (const component_set< L > &lhs, const component_set< L > &rhs)

Detailed Description

template<typename L>
class scribo::component_set< L >

Represents all the components in a document image.

This structure is used to store rich information related to components in an image.

It can be constructed directly from a labeled image and the number of components, or using primitive::extract::components (easier and recommanded) with a binary image.

mln::io::pbm::load(ima, "document.pbm");
typedef mln::image2d<V> L;
V ncomps;
component_set<L> comps = primitive::extract::components(ima, c4(), ncomps);

Each component is associated to an id, component_id_t. This id is equivalent to the component label in the label image (labeled_image()). They are labeled from 1 to nelements() included. Id 0 is reserved for the background which is not considered as an actual component.

A component_set is considered as valid if it has been initialized (i.e. not instantiated with the default constructor).

On construction, information is automatically computed for each components. To iterate over all the components and get that information, use operator()() or info():

for_all_comps(c,comps)
{
const scribo::component_info<L>& comp_info = comps.info(c);
// Some code here...
}

Among component information, a component::Tag tag is stored and used to mark specific components. This tag can be massively updated for all components using update_tags(). The function passed to this method must implement the following interface:

template <typename L>
struct my_function
: mln::Function_v2b< my_function<L> >
{
// Constructor
: components_(components)
{
}
// Core function
bool operator()(const mln_value(L)& l) const
{
return false;
return true;// your test here
}
};

Tags can be used to filter/make a selection of components. Routines performing this selection/filtering automatically are listed in Component Filtering section.

Components considered as separators in the input image (lines, blocks, ...) may be processed separately and are useful of the rest of the layout analysis. This structure allows you to store a binary image of separators which will be used in some routines to prevent wrong regrouping. Note that no component information will be computed for separators. The separator image can be managed with has_separators(), add_separators(), separators(), and clear_separators().

scribo::component_set is the first data structure in the hierarchical representation of a document as explained in Data structures.

See Also
component_info, component::Tag, component::Type, Data structures, Component Filtering.

Definition at line 217 of file component_set.hh.

Constructor & Destructor Documentation

template<typename L>
scribo::component_set< L >::component_set ( )

Default.

template<typename L>
scribo::component_set< L >::component_set ( const mln::util::tracked_ptr< data_t > &  data)

Constructor from internal data.

template<typename L>
scribo::component_set< L >::component_set ( const L &  ima,
const typename L::value ncomps 
)

Constructor from an image ima and the number of labels ncomps.

template<typename L>
scribo::component_set< L >::component_set ( const L &  ima,
const typename L::value ncomps,
const mln::util::array< pair_accu_t > &  attribs,
component::Type  type = component::Undefined 
)

Constructor from an image ima, the number of labels ncomps and attributes values (bounding box and mass center).

template<typename L>
scribo::component_set< L >::component_set ( const L &  ima,
const typename L::value ncomps,
const mln::util::array< pair_data_t > &  attribs,
component::Type  type = component::Undefined 
)

Constructor from an image ima, the number of labels ncomps and attributes values (bounding box and mass center).

Member Function Documentation

void scribo::Serializable< component_set< L > >::accept ( const SerializeVisitor< E2 > &  visitor) const
inherited

Allow this object to be serialized by visitor.

template<typename L>
void scribo::component_set< L >::add_separators ( const typename mln::trait::ch_value< L, bool >::ret ima)

Add a new separator binary image or perform a logical OR with the existing one.

template<typename L>
void scribo::component_set< L >::clear_separators ( )

Clear separator image.

template<typename L>
component_set<L> scribo::component_set< L >::duplicate ( ) const

Create a copy of this component_set<L>

template<typename L>
bool scribo::component_set< L >::has_separators ( ) const

Return true if an image of separator exists.

template<typename L>
const component_info<L>& scribo::component_set< L >::info ( const typename L::value id) const

Return component information for a given component id id.

template<typename L>
component_info<L>& scribo::component_set< L >::info ( const typename L::value id)

Return component information for a given component id id.

template<typename L>
void scribo::component_set< L >::init_ ( const component_set< L > &  model)
protected

INTERNAL_API Duplicate the underlying image and create a new component_set.

template<typename L>
bool scribo::component_set< L >::is_valid ( ) const

A component_set is considered as valid if it has been initialized (i.e.

not instantiated with the default constructor).

template<typename L>
const L& scribo::component_set< L >::labeled_image ( ) const

Return the underlying labeled image.

template<typename L>
L ::value scribo::component_set< L >::nelements ( ) const

Return the number of components, background excluded.

template<typename L>
component_info<L>& scribo::component_set< L >::operator() ( const component_id_t id)

Return component information for a given component id id.

template<typename L>
const component_info<L>& scribo::component_set< L >::operator() ( const component_id_t id) const

Return component information for a given component id id.

template<typename L>
const mln::trait::ch_value< L , bool >::ret& scribo::component_set< L >::separators ( ) const

Return the binary image of separators.

template<typename L>
template<typename F >
void scribo::component_set< L >::update_tags ( const mln::Function_v2b< F > &  f,
component::Tag  tag 
)

Update component tag for which f returns 'False', with tag.

Friends And Related Function Documentation

template<typename L >
std::ostream & operator<< ( std::ostream &  ostr,
const component_set< L > &  info 
)
related
template<typename L >
bool operator== ( const component_set< L > &  lhs,
const component_set< L > &  rhs 
)
related