oln::convert Namespace Reference

Conversion implementation (for example cast, color, or neighborhood to window). More...


Classes

struct  bound
struct  cast
struct  convoutput
struct  force
struct  f_nrgb_to_xyz
struct  f_xyz_to_nrgb
struct  f_rgb_to_hsi
struct  f_hsi_to_rgb
struct  f_rgb_to_hsl
struct  f_hsl_to_rgb
struct  f_rgb_to_hsv
struct  f_hsv_to_rgb
struct  f_rgb_to_nrgb
struct  f_nrgb_to_rgb
struct  f_rgb_to_xyz
struct  f_xyz_to_rgb
struct  f_rgb_to_yiq
struct  f_yiq_to_rgb
struct  f_rgb_to_yuv
struct  f_yuv_to_rgb
struct  stretch
struct  value_to_point
struct  value_to_point::doit_binary
 Convert a binary to a point. More...

struct  value_to_point::doit_not_binary
 Convert a non vectorial to a point. More...

struct  value_to_point< ntg::color< 3, Qbits, S >, Exact >

Functions

template<class C, class B, class UF> internal::compconv1_< C, UF > compconv1 (const abstract::conversion< C, B > &conv, const UF &func)
template<class C, class B, class BF> internal::compconv2_< C, BF > compconv2 (const abstract::conversion< C, B > &conv, const BF &func)
template<class C, class B, class I> mute< I, typename convoutput<
C, B, typename mlc::exact<
I >::ret::value_type >::ret
>::ret 
apply (const abstract::conversion< C, B > &conv, const oln::abstract::image< I > &input)
template<class N> oln::abstract::neighborhood<
N >::win_type 
ng_to_se (const oln::abstract::neighborhood< N > &Ng)
template<class N> oln::abstract::neighborhood<
N >::win_type 
ng_to_cse (const oln::abstract::neighborhood< N > &Ng)
template<unsigned inbits, unsigned outbits> color< 3, outbits, xyz_traits > nrgb_to_xyz (const color< 3, inbits, nrgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, nrgb_traits > xyz_to_nrgb (const color< 3, inbits, xyz_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, hsi_traits > rgb_to_hsi (const color< 3, inbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > hsi_to_rgb (const color< 3, inbits, hsi_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, inbits, hsl_traits > rgb_to_hsl (const color< 3, outbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > hsl_to_rgb (const color< 3, inbits, hsl_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, hsv_traits > rgb_to_hsv (const color< 3, inbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > hsv_to_rgb (const color< 3, inbits, hsv_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, nrgb_traits > rgb_to_nrgb (const color< 3, inbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > nrgb_to_rgb (const color< 3, inbits, nrgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, xyz_traits > rgb_to_xyz (const color< 3, inbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > xyz_to_rgb (const color< 3, outbits, xyz_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, yiq_traits > rgb_to_yiq (const color< 3, inbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > yiq_to_rgb (const color< 3, inbits, yiq_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, yuv_traits > rgb_to_yuv (const color< 3, inbits, rgb_traits > &v)
template<unsigned inbits, unsigned outbits> color< 3, outbits, rgb_traits > yuv_to_rgb (const color< 3, inbits, yuv_traits > &v)
template<class DestValue, class I> mute< I, DestValue >::ret stretch_balance (const oln::abstract::non_vectorial_image< I > &in, const typename mlc::exact< I >::ret::value_type &min_in=ntg::type_traits< typename mlc::exact< I >::ret::value_type >::min(), const typename mlc::exact< I >::ret::value_type &max_in=ntg::type_traits< typename mlc::exact< I >::ret::value_type >::max(), const DestValue &min_out=ntg::type_traits< DestValue >::min(), const DestValue &max_out=ntg::type_traits< DestValue >::max())

Variables

const float sqrt3_3 = sqrt(3) / 3
const float inv_sqrt6 = 1 / sqrt(6)
const float inv_sqrt2 = 1 / sqrt(2)


Detailed Description

Conversion implementation (for example cast, color, or neighborhood to window).

Function Documentation

template<class C, class B, class I>
mute<I, typename convoutput<C, B, typename mlc::exact< I >::ret::value_type>::ret>::ret apply const abstract::conversion< C, B > &  conv,
const oln::abstract::image< I > &  input
[inline]
 

Apply function that retrive the result type within the conversion class.

The core oln::apply function, cannot apply all conversion function, because they do not all define result_type. So we define another apply function here, to apply conversions.

Definition at line 141 of file conversion.hh.

References compconv1().

00142     {
00143       /* CONV can now be wrapped as an Adaptable Unary Function
00144          because we know the input type.  Composing CONV with the
00145          identity for the input type will cause such wrapping to
00146          happen.  */
00147       return apply(compconv1(conv, f_identity<oln_value_type(I)>()), input);
00148     }

template<class C, class B, class UF>
internal::compconv1_<C, UF> compconv1 const abstract::conversion< C, B > &  conv,
const UF &  func
 

Friendly procedure that build an internal::compconv1_ with type deduction.

Definition at line 119 of file conversion.hh.

Referenced by apply().

00120     {
00121       return internal::compconv1_<C, UF>(conv.exact(), func);
00122     }

template<class C, class B, class BF>
internal::compconv2_<C, BF> compconv2 const abstract::conversion< C, B > &  conv,
const BF &  func
 

Likewise for compconv2_.

Definition at line 127 of file conversion.hh.

00128     {
00129       return internal::compconv2_<C, BF>(conv.exact(), func);
00130     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, rgb_traits> hsi_to_rgb const color< 3, inbits, hsi_traits > &  v  ) 
 

Conversion from HSI to RGB color space.

See also:
f_rgb_to_hsl

Definition at line 143 of file rgbhsi.hh.

00144     {
00145       f_hsi_to_rgb<inbits, outbits> f;
00146 
00147       return f(v);
00148     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, rgb_traits> hsl_to_rgb const color< 3, inbits, hsl_traits > &  v  ) 
 

Conversion from HSL to RGB color space.

See also:
f_rgb_to_hsl

Definition at line 217 of file rgbhsl.hh.

00218     {
00219       f_hsl_to_rgb<inbits, outbits> f;
00220       return f(v);
00221     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, rgb_traits> hsv_to_rgb const color< 3, inbits, hsv_traits > &  v  ) 
 

Conversion from HSV to RGB.

See also:
f_rgb_to_hsl

Definition at line 195 of file rgbhsv.hh.

00196     {
00197       f_hsv_to_rgb<inbits, outbits> f;
00198       return f(v);
00199     }

template<class N>
oln::abstract::neighborhood<N>::win_type ng_to_cse const oln::abstract::neighborhood< N > &  Ng  ) 
 

Convert a neighborhood to a window and add the center.

See also:
ng_to_cs

Definition at line 64 of file conversion_ng_se.hh.

References oln::abstract::neighborhood< Exact >::add().

00065     {
00066       typename oln::abstract::neighborhood<N>::win_type output;
00067       oln_iter_type(N) p(Ng);
00068       for_all(p)
00069         output.add(p);
00070       oln_dpoint_type(N) zero;
00071       for (unsigned size = 0; size < N::dim; ++size)
00072         zero.nth(size) = 0;
00073       output.add(zero);
00074       return output;
00075     }

template<class N>
oln::abstract::neighborhood<N>::win_type ng_to_se const oln::abstract::neighborhood< N > &  Ng  ) 
 

Convert a neighborhood to a window.

See also:
ng_to_cse

Definition at line 49 of file conversion_ng_se.hh.

References oln::abstract::neighborhood< Exact >::add().

00050     {
00051       typename oln::abstract::neighborhood<N>::win_type output;
00052       oln_iter_type(N) p(Ng);
00053       for_all(p)
00054         output.add(p);
00055       return output;
00056     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, rgb_traits> nrgb_to_rgb const color< 3, inbits, nrgb_traits > &  v  ) 
 

Conversion from N-RGB to RGB.

See also:
f_rgb_to_hsl

Definition at line 135 of file rgbnrgb.hh.

00136     {
00137       f_nrgb_to_rgb<inbits, outbits> f;
00138 
00139       return f(v);
00140     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, xyz_traits> nrgb_to_xyz const color< 3, inbits, nrgb_traits > &  v  ) 
 

Conversion from N-RGB to XYZ color space.

Deprecated:
A composition should be performed with nrgb->rgb and rgb->xyz.
See also:
f_nrgb_to_xyz for more information.

Definition at line 121 of file nrgbxyz.hh.

00122     {
00123       f_nrgb_to_xyz<inbits, outbits> f;
00124 
00125       return f(v);
00126     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, hsi_traits> rgb_to_hsi const color< 3, inbits, rgb_traits > &  v  ) 
 

Conversion from RGB to HSI color space.

See also:
f_rgb_to_hsl

Definition at line 98 of file rgbhsi.hh.

00099     {
00100       f_rgb_to_hsi<inbits, outbits> f;
00101 
00102       return f(v);
00103     }

template<unsigned inbits, unsigned outbits>
color<3, inbits, hsl_traits> rgb_to_hsl const color< 3, outbits, rgb_traits > &  v  ) 
 

Conversion from RGB to HSL color space.

See also:
f_rgb_to_hsl

Definition at line 142 of file rgbhsl.hh.

00143     {
00144       f_rgb_to_hsl<inbits, outbits> f;
00145       return f(v);
00146     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, hsv_traits> rgb_to_hsv const color< 3, inbits, rgb_traits > &  v  ) 
 

Conversion from RGB to HSV.

See also:
f_rgb_to_hsl

Definition at line 111 of file rgbhsv.hh.

00112     {
00113       f_rgb_to_hsv<inbits, outbits> f;
00114       return f(v);
00115     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, nrgb_traits> rgb_to_nrgb const color< 3, inbits, rgb_traits > &  v  ) 
 

Conversion from RGB to N-RGB.

See also:
f_rgb_to_hsl

Definition at line 90 of file rgbnrgb.hh.

00091     {
00092       f_rgb_to_nrgb<inbits, outbits> f;
00093 
00094       return f(v);
00095     }

template<class DestValue, class I>
mute<I, DestValue>::ret stretch_balance const oln::abstract::non_vectorial_image< I > &  in,
const typename mlc::exact< I >::ret::value_type &  min_in = ntg::type_traits< typename mlc::exact< I >::ret::value_type >::min(),
const typename mlc::exact< I >::ret::value_type &  max_in = ntg::type_traits< typename mlc::exact< I >::ret::value_type >::max(),
const DestValue &  min_out = ntg::type_traits< DestValue >::min(),
const DestValue &  max_out = ntg::type_traits< DestValue >::max()
 

Stretch the value of an image.

This function stretches values between min_in and max_in of an image in, to a range that goes from min_out to max_out.

  • in Input image, must be have scalar values
  • min_in Lower bound of the range in the input. All values smaller than min_in are converted to min_out.
  • max_in Upper bound of the range in the input. All values greater than max_in are converted to max_out.
  • min_out Low bound of the range in the output.
  • max_out Upper bound of the range in the output.
Difference between "apply(stretch<T>(), im)" and "stretch_balance<T>(im)": the first one stretches all the range of oln_value_type(T), the second stretches only values that appear is the image:
#include <oln/basics1d.hh> #include <oln/convert/stretch.hh> #include <ntg/all.hh> #include <iostream> int main() { oln::image1d<ntg::int_u<17> > im(4); im(0) = 0; im(1) = 2; im(2) = 5000; im(3) = 4000; // print "0 170 511 340" //(values of the *image* are dispatched on the range [0..2^9-1]) std::cout << oln::convert::stretch_balance<ntg::int_u<9> >(im) << std::endl; //print " 0 0 19 16" (19 is the result of 5000 * 2^9 / 2^17) //(values of *int_u<17>* are dispatched on the range [0..2^9-1]) std::cout << apply(oln::convert::stretch<ntg::int_u<9> >(), im) << std::endl; }

This function is useful to stretch images of label:

#include <oln/basics2d.hh> #include <oln/convert/stretch.hh> #include <oln/level/cc.hh> #include <ntg/all.hh> #include <iostream> int main() { oln::image2d<ntg::bin> light = oln::load(IMG_IN "face_se.pbm"); //Extraction of the connected components: unsigned card; oln::image2d<ntg::int_u8> cc = oln::level::frontp_connected_component<ntg::int_u8>(light, oln::neighb_c8(), card); oln::io::save(cc, IMG_OUT "oln_convert_stretch_dark.pgm"); oln::io::save(oln::convert::stretch_balance<ntg::int_u8>(cc), IMG_OUT "oln_convert_stretch_balance.pgm"); }
face_se_pbm.png
=> Without stretch_balance:
oln_convert_stretch_dark.png
=> With stretch_balance:
oln_convert_stretch_balance.png

Definition at line 166 of file stretch.hh.

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

00173     {
00174       typedef typename
00175         ntg_is_a(DestValue, ntg::non_vectorial)::ensure_type ensure_type;
00176 
00177       typename mute<I, DestValue>::ret out(in.size());
00178 
00179       //FIXME: I would like to remove the static_cast.
00180       std::vector<ntg_cumul_type(DestValue)>
00181         tab(static_cast<int>(max_in - min_in + 1));
00182       typedef typename std::set<oln_value_type(I)> set_type;
00183       set_type s;
00184       oln_iter_type(I) it(in);
00185 
00186       for_all(it)
00187         if (in[it] <= max_in && in[it] >= min_in)
00188               s.insert(in[it]);
00189       if (s.size() == 1)
00190         {
00191           for_all(it)
00192             out[it] = ntg_zero_val(DestValue);
00193           return out;
00194         }
00195       {
00196         unsigned cpt = 0;
00197         for (typename set_type::const_iterator it(s.begin());
00198              it != s.end(); ++it, ++cpt)
00199           tab[*it - min_in] = cpt * (max_out - min_out) / (s.size() - 1);
00200       }
00201       for_all(it)
00202         if (min_in <= in[it])
00203           {
00204             if (in[it] <= max_in)
00205               out[it] = tab[in[it] - min_in] + min_out;
00206             else
00207               out[it] = max_out;
00208           }
00209       else
00210         out[it] = min_out;
00211       return out;
00212     }

template<unsigned inbits, unsigned outbits>
color<3, outbits, nrgb_traits> xyz_to_nrgb const color< 3, inbits, xyz_traits > &  v  ) 
 

Conversion from XYZ to N-RGB color space.

Deprecated:
a composition should be performed with xyz->rgb and rgb->nrgb.
See also:
f_nrgb_to_xyz for more information.

Definition at line 171 of file nrgbxyz.hh.

00172     {
00173       f_xyz_to_nrgb<inbits, outbits> f;
00174 
00175       return f(v);
00176     }


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