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) |
mute<I, DestType>::ret oln::level::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.
input | Image of markers. | |
se | Neighborhood. | |
nb_label | Optional. Return the number of labels (including the background); i.e. connected components are labelled from 1 to ![]() |
#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; }
Definition at line 98 of file cc.hh.
References fill(), oln::abstract::image< Exact >::hold(), and oln::abstract::image< Exact >::size().
Referenced by frontp_connected_component().
00101 { 00102 typename mute<I, DestType>::ret output(input.size()); 00103 level::fill(output, 0); 00104 00105 typedef std::set<oln_point_type(I), 00106 oln::internal::default_less<oln_point_type(I) > > 00107 points_set; 00108 00109 I is_processed(input.size()); 00110 level::fill(is_processed, false); 00111 DestType cur_label = 1; 00112 oln_iter_type(I) p(input); 00113 for_all(p) if ((input[p] == true)&& (is_processed[p] == false)) 00114 { 00115 //propagation front 00116 points_set component; 00117 component.insert(p.cur()); 00118 points_set points_to_process; 00119 points_to_process.insert(p.cur()); 00120 while (!points_to_process.empty()) 00121 { 00122 //set label and net neighbors 00123 points_set next; 00124 for (typename points_set::const_iterator i = 00125 points_to_process.begin(); 00126 i != points_to_process.end(); 00127 ++i) 00128 { 00129 component.insert(*i); 00130 oln_neighb_type(E) p_prime(se, *i); 00131 for_all (p_prime) if(input.hold(p_prime) && 00132 (input[p_prime] == true)) 00133 next.insert(p_prime.cur()); 00134 } 00135 points_to_process.clear(); 00136 set_difference(next.begin(), next.end(), 00137 component.begin(), component.end(), 00138 inserter(points_to_process, 00139 points_to_process.begin()), 00140 oln::internal::default_less<oln_point_type(I) >()); 00141 } 00142 for (typename points_set::const_iterator i = component.begin(); 00143 i != component.end(); 00144 ++i) 00145 { 00146 output[*i] = cur_label; 00147 is_processed[*i] = true; 00148 } 00149 cur_label++; 00150 } 00151 nb_label = cur_label; 00152 return output; 00153 }
bool oln::level::is_equal | ( | const abstract::image< I1 > & | input1, | |
const abstract::image< I2 > & | input2 | |||
) | [inline] |
Tests if input1 is equal to input2.
Definition at line 112 of file compare.hh.
References oln::abstract::image< Exact >::size().
Referenced by oln::morpho::sequential::geodesic_reconstruction_dilation(), oln::morpho::sure::geodesic_reconstruction_dilation(), oln::morpho::sequential::geodesic_reconstruction_erosion(), and oln::morpho::sure::geodesic_reconstruction_erosion().
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 }
bool oln::level::is_greater | ( | const abstract::image< I1 > & | input1, | |
const abstract::image< I2 > & | input2 | |||
) | [inline] |
Tests if all pixels of input1 are greater than input2.
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 }
bool oln::level::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.
Definition at line 43 of file compare.hh.
References oln::abstract::image< Exact >::size().
Referenced by oln::morpho::sure::geodesic_dilation(), oln::morpho::geodesic_dilation(), oln::morpho::sure::geodesic_erosion(), oln::morpho::geodesic_erosion(), oln::morpho::hybrid::geodesic_reconstruction_dilation(), oln::morpho::sequential::geodesic_reconstruction_dilation(), oln::morpho::sure::geodesic_reconstruction_dilation(), oln::morpho::hybrid::geodesic_reconstruction_erosion(), oln::morpho::sequential::geodesic_reconstruction_erosion(), and oln::morpho::sure::geodesic_reconstruction_erosion().
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 }
bool oln::level::is_lower | ( | const abstract::image< I1 > & | input1, | |
const abstract::image< I2 > & | input2 | |||
) | [inline] |
Tests if all pixel of input1 are lower than input2.
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 }
bool oln::level::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.
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 }
void oln::level::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.
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 }
void oln::level::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.
#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"); }
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 }