oln::utils Namespace Reference

Utilities, such as statistics. More...


Classes

class  buffer
 Buffer used for MD5 data type abstraction. More...
struct  hist_traits
 Traits for oln::utils::abstract::histogram hierarchy. More...
struct  hist_traits< histogram< T, CPT, V2P, Exact > >
 Traits for oln::utils::abstract::histogram hierarchy. More...
class  histogram
struct  hist_traits< histogram_minmax< T, CPT, V2P, Exact > >
class  histogram_minmax
struct  hist_traits< histogram_min< T, CPT, V2P, Exact > >
class  histogram_min
struct  hist_traits< histogram_max< T, CPT, V2P, Exact > >
class  histogram_max
struct  select_distrib_sort
struct  select_distrib_sort< true >
class  key
 16 bytes key More...
class  MD5
 Class used to compute a MD5 digest. More...
struct  select_q_sort
struct  select_q_sort< true >
class  se_stat
 Compute the variance and the mean within a window. More...
struct  f_minmax
 Unary function that stores the min and the max. More...
struct  f_moments
 Computes the mean, the variance and store the min, the max. More...
class  timer

Namespaces

namespace  abstract
 Abstract utilities.
namespace  internal
 Internal purpose only.

Functions

template<class T>
mlc::exact< T >::ret::value_type min (const abstract::histogram< T > &hist)
template<class T>
mlc::exact< T >::ret::value_type max (const abstract::histogram< T > &hist)
template<typename T, typename CPT, class V2P, class Exact>
min (histogram_minmax< T, CPT, V2P, Exact > &hist)
 Minimum non-zero value of an histogram.
template<typename T, typename CPT, class V2P, class Exact>
min (histogram_min< T, CPT, V2P, Exact > &hist)
 Minimum non-zero value of an histogram.
template<typename T, typename CPT, class V2P, class Exact>
max (histogram_minmax< T, CPT, V2P, Exact > &hist)
 Maximum non-zero value of an histogram.
template<typename T, typename CPT, class V2P, class Exact>
max (histogram_max< T, CPT, V2P, Exact > &hist)
 Maximum non-zero value of an histogram.
template<class I>
void distrib_sort (const oln::abstract::non_vectorial_image< I > &im, std::vector< typename mlc::exact< I >::ret::point_type > &v)
template<class I>
void distrib_sort_inv (const oln::abstract::non_vectorial_image< I > &im, std::vector< typename mlc::exact< I >::ret::point_type > &v)
template<class I>
key md5 (const oln::abstract::non_vectorial_image< I > &im)
 Compute The Md5 value of an image.
template<class I>
key md5 (const oln::abstract::vectorial_image< I > &im)
 Compute The Md5 value of an image.
template<class I>
void qsort (const oln::abstract::non_vectorial_image< I > &im, std::vector< typename mlc::exact< I >::ret::point_type > &v)
 Sort points of an image in increasing order.
template<class I>
void qsort_inv (const oln::abstract::non_vectorial_image< I > &im, std::vector< typename mlc::exact< I >::ret::point_type > &v)
 Sort points of an image in decreasing order.


Detailed Description

Utilities, such as statistics.

Function Documentation

template<class I>
void oln::utils::distrib_sort ( const oln::abstract::non_vectorial_image< I > &  im,
std::vector< typename mlc::exact< I >::ret::point_type > &  v 
)

Sort the values of an image, and store the result in a vector

This sort is efficient.

Definition at line 676 of file histogram.hh.

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

Referenced by oln::morpho::slow::f_tarjan_map< I, D, Env >::f_tarjan_map(), and oln::utils::select_distrib_sort< true >::operator()().

00678     {
00679       typedef oln_value_type(I) val;
00680 
00681       // check the size
00682       precondition(v.size() == im.npoints());
00683 
00684       // calculate the histogram of the image
00685       utils::histogram<val> histo(im);
00686 
00687       // Initialize the array of pointer to the point in the result.
00688       // With the histogram the number of each color can be deduced and
00689       // then it calculates an array of pointer for quick access to each
00690       // value of the image.
00691       const ntg_cumul_type(val) card = ntg_max_val(val)
00692                                         - ntg_min_val(val) + 1;
00693       std::vector<oln_point_type(I)* > ptr(card);
00694       ptr[0] = &(v[0]);
00695       for (ntg_cumul_type(val) i = 1; i < card; ++i)
00696         ptr[i] = ptr[i - 1] + histo[i - 1 + ntg_min_val(val)];
00697 
00698       // Now iterate on the image to sort point in the order of their
00699       // level
00700       oln_iter_type(I) p(im);
00701       for_all(p)
00702         *(ptr[unsigned(im[p] - ntg_min_val(val))]++) = p;
00703     }

template<class I>
void oln::utils::distrib_sort_inv ( const oln::abstract::non_vectorial_image< I > &  im,
std::vector< typename mlc::exact< I >::ret::point_type > &  v 
)

Inverted sort of the values of an image, and store the result in a vector

This sort is efficient.

Definition at line 716 of file histogram.hh.

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

Referenced by oln::morpho::slow::f_tarjan_map< I, D, Env >::f_tarjan_map(), and oln::utils::select_distrib_sort< reverse >::operator()().

00718     {
00719       typedef oln_value_type(I) val;
00720 
00721       precondition(v.size() == im.npoints());
00722 
00723       utils::histogram<val> histo(im);
00724 
00725       const ntg_cumul_type(val) card = ntg_max_val(val)
00726                                         - ntg_min_val(val) + 1;
00727       std::vector<oln_point_type(I)* > ptr(card);
00728       ptr[card - 1] = &(v[0]);
00729 
00730       for (ntg_signed_cumul_type(val) i = card - 2; i >= 0; --i)
00731         ptr[i] = ptr[i + 1] + histo[i + 1 + ntg_min_val(val)];
00732 
00733       oln_iter_type(I) p(im);
00734       for_all(p)
00735         *(ptr[unsigned(im[p] - ntg_min_val(val))]++) = p;
00736     }

template<class T>
mlc::exact< T >::ret::value_type oln::utils::max ( const abstract::histogram< T > &  hist  )  [inline]

Maximum value of an histogram.

Return the higher value within the image used to build the histogram.

Note:
It can be slow when the histogram is sparse because it iterates over a large range of 0. Use histogram_max or histogram_minmax instead.
See also:
histogram_max

Definition at line 330 of file histogram.hh.

References ntg::pred().

00331     {
00332       typedef typename ntg_is_a(oln_value_type(T),
00333                                 ntg::non_vectorial)::ensure_type ensure_type;
00334 
00335       oln_value_type(T) i;
00336       for (i = ntg_max_val(oln_value_type(T));
00337            i != ntg_min_val(oln_value_type(T));
00338            i = ntg::pred(i))
00339         if (hist[i] > ntg_zero_val(oln_cpt_type(T)))
00340           break;
00341       return i;
00342     }

template<class I>
key oln::utils::md5 ( const oln::abstract::vectorial_image< I > &  im  )  [inline]

Compute The Md5 value of an image.

Parameters:
I Exact type of the image.
Vectorial image version.

Definition at line 516 of file md5.hh.

template<class I>
key oln::utils::md5 ( const oln::abstract::non_vectorial_image< I > &  im  )  [inline]

Compute The Md5 value of an image.

Parameters:
I Exact type of the image.
Non vectorial image version.

Definition at line 499 of file md5.hh.

template<class T>
mlc::exact< T >::ret::value_type oln::utils::min ( const abstract::histogram< T > &  hist  )  [inline]

Minimum value of an histogram.

Return the smaller value within the image used to build the histogram.

Note:
It can be slow when the histogram is sparse because it iterates over a large range of 0. Use histogram_min or histogram_minmax instead.
See also:
histogram_min

Definition at line 305 of file histogram.hh.

References ntg::succ().

00306     {
00307       typedef typename ntg_is_a(oln_value_type(T),
00308                                 ntg::non_vectorial)::ensure_type ensure_type;
00309 
00310       oln_value_type(T) i;
00311       for (i = ntg_min_val(oln_value_type(T));
00312            i != ntg_max_val(oln_value_type(T));
00313            i = ntg::succ(i))
00314         if (hist[i] > ntg_zero_val(oln_cpt_type(T)))
00315           break;
00316       return i;
00317     }

template<class I>
void oln::utils::qsort ( const oln::abstract::non_vectorial_image< I > &  im,
std::vector< typename mlc::exact< I >::ret::point_type > &  v 
)

Sort points of an image in increasing order.

Parameters:
I Exact type of the image.

Definition at line 139 of file qsort.hh.

Referenced by oln::utils::select_q_sort< true >::operator()().

00141     {
00142       oln_iter_type(I)  it(im);
00143 
00144       for_all(it)
00145         v.push_back(oln_point_type(I)(it));
00146       internal::cmp_pt_value<I> c(im);
00147 
00148       std::sort(v.begin(), v.end(), c);
00149     }

template<class I>
void oln::utils::qsort_inv ( const oln::abstract::non_vectorial_image< I > &  im,
std::vector< typename mlc::exact< I >::ret::point_type > &  v 
)

Sort points of an image in decreasing order.

Parameters:
I Exact type of the image.

Definition at line 161 of file qsort.hh.

Referenced by oln::utils::select_q_sort< reverse >::operator()().

00163     {
00164       oln_iter_type(I)  it(im);
00165 
00166       for_all(it)
00167         v.push_back(oln_point_type(I)(it));
00168 
00169       internal::cmp_pt_value_inv<I> c(im);
00170 
00171       std::sort(v.begin(), v.end(), c);
00172     }


Generated on Tue Feb 20 20:29:54 2007 for Olena by  doxygen 1.5.1