oln::level Namespace Reference

Level algorithm implementation. More...


Classes

struct  f_invert
 Fctor to invert a value. More...

class  hlut
 Look up table "id" version. More...

class  hlut_def
 Look up table "default" version. More...

class  threshold
 Threshold the value of the image. More...


Functions

template<class DestType, class I, class E> mute< I, DestType >::ret frontp_connected_component (const abstract::binary_image< I > &input, const abstract::neighborhood< E > &se, unsigned &nb_label)
 Processing frontp_connected_component extract the connected components.

template<class DestType, class I, class E> mute< I, DestType >::ret frontp_connected_component (const abstract::image< I > &input, const abstract::neighborhood< E > &se)
template<class I> mute< I, ntg::bin >::ret extract_i_cc (const abstract::image< I > &input, typename mlc::exact< I >::ret::value_type i)
template<class I> mlc::exact< I >::ret::value_type get_n_cc (const abstract::image< I > &input)
template<class I1, class I2> bool is_greater_or_equal (const abstract::image< I1 > &input1, const abstract::image< I2 > &input2)
 Tests if all pixels of input1 are greater or equal than input2.

template<class I1, class I2> bool is_greater (const abstract::image< I1 > &input1, const abstract::image< I2 > &input2)
 Tests if all pixels of input1 are greater than input2.

template<class I1, class I2> bool is_lower_or_equal (const abstract::image< I1 > &input1, const abstract::image< I2 > &input2)
 Tests if all pixels of input1 are lower or equal than input2.

template<class I1, class I2> bool is_lower (const abstract::image< I1 > &input1, const abstract::image< I2 > &input2)
 Tests if all pixel of input1 are lower than input2.

template<class I1, class I2> bool is_equal (const abstract::image< I1 > &input1, const abstract::image< I2 > &input2)
 Tests if input1 is equal to input2.

template<class DestType, class I, class N> mute< I, DestType >::ret connected_component (const abstract::binary_image_with_dim< 2, I > &input, const abstract::neighborhood< N > &Ng)
template<class I> oln::mute< I >::ret fill (abstract::image< I > &im, const typename mlc::exact< I >::ret::value_type &val)
 Fill the image with a value.

template<class I> oln::mute< I >::ret invert (const abstract::image< I > &input)
 Return the image inverted.

template<class I> void invert_self (abstract::image< I > &input)
 Invert an image.

template<class I> void set_level (abstract::image_with_dim< 2, I > &inout, const typename mlc::exact< I >::ret::point_type &p1, const typename mlc::exact< I >::ret::point_type &p2, typename mlc::exact< I >::ret::value_type level)
 Draw a line between two points in the image.

template<class I, class BoxType> void set_level (abstract::image_with_dim< 2, I > &inout, BoxType &box, const typename mlc::exact< I >::ret::value_type &level)


Detailed Description

Level algorithm implementation.

Function Documentation

template<class DestType, class I, class E>
mute<I, DestType>::ret frontp_connected_component const abstract::binary_image< I > &  input,
const abstract::neighborhood< E > &  se,
unsigned &  nb_label
 

Processing frontp_connected_component extract the connected components.

It removes the small (in area) connected components of the upper level sets of input using se as structural element.

REF: The implementation uses front propagation.

Precondition:
the input must be a binary image.
  • input Image of markers.
  • se Neighbourhood.
  • nb_label Returns the number of label (optional).
Returns:
An image of type DestType.
See also:
level::connected_component
Todo:
FIXME: Should probably be turned into a class.
#include <oln/basics2d.hh> #include <oln/level/cc.hh> #include <ntg/all.hh> #include <iostream> int main() { unsigned card; oln::image2d<ntg::bin> light = oln::load(IMG_IN "face_se.pbm"); save(oln::level::frontp_connected_component<ntg::int_u8>(light, oln::neighb_c8(), card), IMG_OUT "oln_level_frontp_connected_component.pgm"); std::cout << card << " connected components" << std::endl; }
face_se_pbm.png
=>
oln_level_frontp_connected_component.png

Definition at line 96 of file cc.hh.

References oln::abstract::image< Exact >::hold(), and oln::abstract::image< Exact >::size().

00099     {
00100       typename mute<I, DestType>::ret output(input.size());
00101       level::fill(output, 0);
00102 
00103       typedef std::set<oln_point_type(I),
00104                        oln::internal::default_less<oln_point_type(I) > >
00105               points_set;
00106 
00107       I is_processed(input.size());
00108       level::fill(is_processed, false);
00109       DestType cur_label = 1;
00110       oln_iter_type(I) p(input);
00111       for_all(p) if ((input[p] == true)&& (is_processed[p] == false))
00112         {
00113           //propagation front
00114           points_set component;
00115           component.insert(p.cur());
00116           points_set points_to_process;
00117           points_to_process.insert(p.cur());
00118           while (!points_to_process.empty())
00119             {
00120               //set label and net neighbors
00121               points_set next;
00122               for (typename points_set::const_iterator i =
00123                      points_to_process.begin();
00124                    i != points_to_process.end();
00125                    ++i)
00126                 {
00127                   component.insert(*i);
00128                   oln_neighb_type(E) p_prime(se, *i);
00129                   for_all (p_prime) if(input.hold(p_prime) &&
00130                                        (input[p_prime] == true))
00131                     next.insert(p_prime.cur());
00132                 }
00133               points_to_process.clear();
00134               set_difference(next.begin(), next.end(),
00135                              component.begin(), component.end(),
00136                              inserter(points_to_process,
00137                                       points_to_process.begin()),
00138                              oln::internal::default_less<oln_point_type(I) >());
00139             }
00140           for (typename points_set::const_iterator i = component.begin();
00141                i != component.end();
00142                ++i)
00143             {
00144               output[*i] = cur_label;
00145               is_processed[*i] = true;
00146             }
00147           cur_label++;
00148         }
00149       nb_label = cur_label;
00150       return output;
00151     }

template<class I1, class I2>
bool is_equal const abstract::image< I1 > &  input1,
const abstract::image< I2 > &  input2
[inline]
 

Tests if input1 is equal to input2.

Precondition:
input1.size() == input2.size()

Definition at line 112 of file compare.hh.

References oln::abstract::image< Exact >::size().

00114     {
00115       precondition(input1.size() == input2.size());
00116       oln_iter_type(I1) p(input1);
00117       for_all (p)
00118         if (!(input1[p] == input2[p]))
00119           return false;
00120       return true;
00121     }

template<class I1, class I2>
bool is_greater const abstract::image< I1 > &  input1,
const abstract::image< I2 > &  input2
[inline]
 

Tests if all pixels of input1 are greater than input2.

Precondition:
input1.size() == input2.size()

Definition at line 60 of file compare.hh.

References oln::abstract::image< Exact >::size().

00062     {
00063       precondition(input1.size() == input2.size());
00064       oln_iter_type(I1) p(input1);
00065       for_all (p)
00066         if (!(input1[p] > input2[p]))
00067           return false;
00068       return true;
00069     }

template<class I1, class I2>
bool is_greater_or_equal const abstract::image< I1 > &  input1,
const abstract::image< I2 > &  input2
[inline]
 

Tests if all pixels of input1 are greater or equal than input2.

Precondition:
input1.size() == input2.size()

Definition at line 43 of file compare.hh.

References oln::abstract::image< Exact >::size().

00045     {
00046       precondition(input1.size() == input2.size());
00047       oln_iter_type(I1) p(input1);
00048       for_all (p)
00049         if (!(input1[p] >= input2[p]))
00050           return false;
00051       return true;
00052     }

template<class I1, class I2>
bool is_lower const abstract::image< I1 > &  input1,
const abstract::image< I2 > &  input2
[inline]
 

Tests if all pixel of input1 are lower than input2.

Precondition:
input1.size() == input2.size()

Definition at line 94 of file compare.hh.

References oln::abstract::image< Exact >::size().

00096     {
00097       precondition(input1.size() == input2.size());
00098       oln_iter_type(I1) p(input1);
00099       for_all (p)
00100         if (!(input1[p] < input2[p]))
00101           return false;
00102       return true;
00103     }

template<class I1, class I2>
bool is_lower_or_equal const abstract::image< I1 > &  input1,
const abstract::image< I2 > &  input2
[inline]
 

Tests if all pixels of input1 are lower or equal than input2.

Precondition:
input1.size() == input2.size()

Definition at line 77 of file compare.hh.

References oln::abstract::image< Exact >::size().

00079     {
00080       precondition(input1.size() == input2.size());
00081       oln_iter_type(I1) p(input1);
00082       for_all (p)
00083         if (!(input1[p] <= input2[p]))
00084           return false;
00085       return true;
00086     }

template<class I, class BoxType>
void set_level abstract::image_with_dim< 2, I > &  inout,
BoxType &  box,
const typename mlc::exact< I >::ret::value_type &  level
 

Draw a box in the image.

See also:
set_level for an example.

Definition at line 141 of file set_level.hh.

References set_level().

00144     {
00145       if (box.card() != 0)
00146         {
00147           dpoint2d drows(box.top().row() - box.bottom().row(), 0);
00148           dpoint2d dcols(0, box.top().col() - box.bottom().col());
00149           set_level(inout, box.top(), box.top() - drows, level);
00150           set_level(inout, box.top(), box.top() - dcols, level);
00151           set_level(inout, box.bottom(), box.bottom() + drows, level);
00152           set_level(inout, box.bottom(), box.bottom() + dcols, level);
00153         }
00154     }

template<class I>
void set_level abstract::image_with_dim< 2, I > &  inout,
const typename mlc::exact< I >::ret::point_type &  p1,
const typename mlc::exact< I >::ret::point_type &  p2,
typename mlc::exact< I >::ret::value_type  level
 

Draw a line between two points in the image.

  • inout a 2d image.
  • p1 A point in the image.
  • p2 A point in the image (p1 and p2 can be swaped).
  • level Value of the line.
#include <oln/basics2d.hh> #include <oln/level/set_level.hh> #include <ntg/all.hh> int main() { oln::image2d<ntg::int_u8> in = oln::load(IMG_IN "lena256.pgm"); oln::coord R = in.nrows(); oln::coord C = in.ncols(); //Draw the line oln::level::set_level(in, oln::point2d(R * 1/4, C* 1/2), oln::point2d(R * 4/5, C* 7/8), 0); oln::box<oln::point2d> b; b.add(oln::point2d(R * 1/6, C * 1/6)); b.add(oln::point2d(R * 4/5, C * 1/3)); //Draw the box oln::level::set_level(in, b, 255); save(in, IMG_OUT "oln_level_set_level.pgm"); }
lena256_pgm.png
=>
oln_level_set_level.png

Definition at line 83 of file set_level.hh.

Referenced by set_level().

00087     {
00088       int iRow1 = p1.row();
00089       int iCol1 = p1.col();
00090       int iRow2 = p2.row();
00091       int iCol2 = p2.col();
00092       int dRow = ( iRow2 > iRow1 ? iRow2 - iRow1 : iRow1 - iRow2 );
00093       int ddRow = 2 * dRow;
00094       int dCol = ( iCol2 > iCol1 ? iCol2 - iCol1 : iCol1 - iCol2 );
00095       int ddCol = 2 * dCol;
00096       int sRow = ( iRow2 != iRow1 ? ( iRow2 > iRow1 ? 1 : -1 ) : 0 );
00097       int sCol = ( iCol2 != iCol1 ? ( iCol2 > iCol1 ? 1 : -1 ) : 0 );
00098       int i, e;
00099       int iRow = iRow1;
00100       int iCol = iCol1;
00101 
00102       if ( dCol > dRow )
00103         {
00104           e = ddRow - dCol;
00105           for ( i = 0; i < dCol; ++i )
00106             {
00107               inout(iRow, iCol) = level;
00108               while ( e >= 0 )
00109                 {
00110                   iRow += sRow;
00111                   e -= ddCol;
00112                 }
00113               iCol += sCol;
00114               e += ddRow;
00115             }
00116         }
00117       else
00118         {
00119           e = ddCol - dRow;
00120           for ( i = 0; i < dRow; ++i )
00121             {
00122               inout(iRow,iCol) = level;
00123               while ( e >= 0 )
00124                 {
00125                   iCol += sCol;
00126                   e -= ddRow;
00127                 }
00128               iRow += sRow;
00129               e += ddCol;
00130             }
00131         }
00132       inout(iRow,iCol) = level;
00133     }


Generated on Thu Apr 15 20:16:29 2004 for Olena by doxygen 1.3.6-20040222