#include <attribute_union_find.hh>
Collaboration diagram for oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >:
Public Types | |
typedef mlc::exact< T >::ret::point_type | point_type |
Associated point type. | |
typedef mlc::exact< T >::ret::value_type | data_type |
Associated data_type. | |
typedef oln::mute< T >::ret | image_type |
Image type to open/close. | |
typedef ATTRIBUTE::lambda_type | lambda_type |
Threshold type. | |
typedef Env | env_type |
Environment type. | |
Public Member Functions | |
tarjan_set (const image_type &ima, const env_type &env) | |
tarjan_set constructor. | |
template<bool closing, class N> | |
image_type | get_comptute (const lambda_type &lambda, const abstract::neighborhood< N > &Ng) |
Main method to perform an attribute opening/closing. | |
Protected Member Functions | |
void | make_set (const point_type &x) |
Make a new component from a point. | |
point_type | find_root (const point_type &x) |
find the root of a component. | |
bool | criterion (const point_type &x, const point_type &y) |
Check if two components should be merged. | |
void | uni (const point_type &n, const point_type &p) |
Do union of two components. | |
bool | is_proc (const point_type &p) const |
Tells if a point has been proceded. | |
Static Protected Member Functions | |
static const point_type & | ACTIVE () |
Return the value of an active point. | |
static const point_type & | INACTIVE () |
Return the value of an inactive point. | |
Protected Attributes | |
const image_type & | input_ |
Input image. | |
mute< T, point_type >::ret | parent_ |
Give a parent of a point. | |
mute< T, ATTRIBUTE >::ret | aux_data_ |
Image to store attributes. | |
const lambda_type * | lambda_ |
Threshold. | |
const env_type | env_ |
Environment. |
T | Exact type of images to process. | |
ATTRIBUTE | Exact type of attribute to use. | |
Env | Type of environment to use. |
Definition at line 57 of file attribute_union_find.hh.
oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::tarjan_set | ( | const image_type & | ima, | |
const env_type & | env | |||
) | [inline] |
tarjan_set constructor.
ima | Image to open/close. | |
env | Environment to use to compute attributes. |
Definition at line 70 of file attribute_union_find.hh.
References oln::level::fill(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::INACTIVE(), and oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::parent_.
00070 : input_(ima), 00071 parent_(ima.size()), 00072 aux_data_(ima.size()), 00073 env_(env) 00074 { 00075 level::fill(parent_, INACTIVE()); 00076 }
image_type oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::get_comptute | ( | const lambda_type & | lambda, | |
const abstract::neighborhood< N > & | Ng | |||
) | [inline] |
Main method to perform an attribute opening/closing.
closing | True -> a closing is performed, an opening otherwise. | |
lambda | Threshold to use for attribute growing. | |
Ng | Neighborhood to use in the algorithm. |
Definition at line 88 of file attribute_union_find.hh.
References oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::ACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::aux_data_, oln::abstract::neighborhood< Exact >::delta(), oln::level::fill(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::INACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::input_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::is_proc(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::lambda_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::make_set(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::parent_, and oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::uni().
00090 { 00091 lambda_ = λ 00092 00093 std::vector<point_type> I;//(/*input_.npoints()*/); 00094 00095 // FIXME: make both version avialble: qsort and dsort 00096 // oln::utils::select_distrib_sort<closing>()(input_, I); 00097 oln::utils::select_q_sort<closing>()(input_, I); 00098 00099 level::fill(aux_data_, ntg_sup_val(lambda_type)); 00100 aux_data_.border_adapt_assign(Ng.delta(), ntg_sup_val(lambda_type)); 00101 00102 // We are ready to perform stuff 00103 for (unsigned int p = 0; p < I.size(); ++p) 00104 { 00105 point_type p_p = I[p]; 00106 make_set(p_p); 00107 oln_neighb_type(N) Q_prime(Ng, p_p); 00108 for_all (Q_prime) 00109 if (is_proc(Q_prime)) 00110 uni(Q_prime.cur(), p_p); 00111 } 00112 00113 // Resolving phase 00114 image_type output(input_.size()); 00115 for (int p = I.size() - 1; p >= 0; --p) 00116 { 00117 point_type p_p = I[p]; 00118 if ((parent_[p_p] == ACTIVE()) || (parent_[p_p] == INACTIVE())) 00119 output[p_p] = input_[p_p]; 00120 else 00121 output[p_p] = output[parent_[p_p]]; 00122 // this code is equivalent to 00123 // output[I[p].first] = input_[find_root(I[p].first)]; 00124 00125 } 00126 return output; 00127 }
void oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::make_set | ( | const point_type & | x | ) | [inline, protected] |
Make a new component from a point.
Definition at line 174 of file attribute_union_find.hh.
References oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::ACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::aux_data_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::env_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::INACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::input_, and oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::parent_.
Referenced by oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::get_comptute().
00175 { 00176 precondition(parent_[x] == INACTIVE()); 00177 parent_[x] = ACTIVE(); 00178 aux_data_[x] = ATTRIBUTE(input_, x, env_); 00179 }
point_type oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::find_root | ( | const point_type & | x | ) | [inline, protected] |
find the root of a component.
Definition at line 186 of file attribute_union_find.hh.
References oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::ACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::INACTIVE(), and oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::parent_.
Referenced by oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::uni().
00187 { 00188 if ((parent_[x] != ACTIVE()) && (parent_[x] != INACTIVE())) 00189 { 00190 parent_[x] = find_root(parent_[x]); 00191 return parent_[x]; 00192 } 00193 else 00194 return x; 00195 }
bool oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::criterion | ( | const point_type & | x, | |
const point_type & | y | |||
) | [inline, protected] |
Check if two components should be merged.
Definition at line 203 of file attribute_union_find.hh.
References oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::ACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::aux_data_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::INACTIVE(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::input_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::lambda_, and oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::parent_.
Referenced by oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::uni().
00204 { 00205 precondition((parent_[x] == ACTIVE()) || (parent_[x] == INACTIVE())); 00206 precondition((parent_[y] == ACTIVE()) || (parent_[y] == INACTIVE())); 00207 return ( (input_[x] == input_[y]) || (aux_data_[x] < *lambda_)); 00208 }
void oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::uni | ( | const point_type & | n, | |
const point_type & | p | |||
) | [inline, protected] |
Do union of two components.
Definition at line 216 of file attribute_union_find.hh.
References oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::aux_data_, oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::criterion(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::find_root(), oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::lambda_, and oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::parent_.
Referenced by oln::morpho::fast::tarjan::tarjan_set< T, ATTRIBUTE, Env >::get_comptute().
00217 { 00218 point_type r = find_root(n); 00219 if (r != p) 00220 if (criterion(r,p)) 00221 { 00222 aux_data_[p] += aux_data_[r]; 00223 parent_[r] = p; 00224 } 00225 else 00226 { 00227 aux_data_[p] = *lambda_; 00228 } 00229 }