00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef OLENA_MORPHER_SUBQ_MORPHER_HH
00031 # define OLENA_MORPHER_SUBQ_MORPHER_HH
00032
00033 # include "generic_morpher.hh"
00034
00035 namespace oln {
00036
00037 namespace morpher {
00038
00039 template <class SrcType, unsigned N, class Exact = mlc::final>
00040 struct subq_morpher;
00041
00042
00055 template <class T, unsigned N>
00056 struct color_mute
00057 {
00058 };
00059
00061 template <unsigned nbcomps_,
00062 unsigned nbits_,
00063 template <unsigned> class color_system,
00064 unsigned N>
00065 struct color_mute<ntg::color<nbcomps_, nbits_, color_system>, N>
00066 {
00067 typedef ntg::color<nbcomps_, N, color_system> ret;
00069 enum { nbcomps = nbcomps_ };
00071 };
00072
00073
00074
00075 }
00076
00085 template <class SrcType, unsigned N, class Exact>
00086 struct image_id<oln::morpher::subq_morpher<SrcType, N, Exact> >
00087 {
00088 enum {dim = SrcType::dim};
00090 typedef oln_impl_type(SrcType) impl_type;
00092 typedef typename oln::morpher::color_mute<oln_value_type(SrcType), N>::ret value_type;
00094 typedef typename mlc::exact_vt<oln::morpher::subq_morpher<SrcType, N, Exact>,
00095 Exact>::ret exact_type;
00096
00097 typedef oln_point_type(SrcType) point_type;
00098 };
00099
00108 template <class SrcType, unsigned N, class Exact>
00109 struct image_traits <oln::morpher::subq_morpher<SrcType, N, Exact> > :
00110 public image_traits<oln::morpher::abstract::generic_morpher<SrcType,
00111 typename image_id<oln::morpher::subq_morpher<SrcType, N, Exact> >::exact_type> >
00112 {
00113 };
00114
00115 namespace morpher {
00116
00117
00118
00132 template <class SrcType, unsigned N, class Exact>
00133 struct subq_morpher:
00134 public abstract::generic_morpher<SrcType,
00135 typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type>
00136 {
00137
00139 typedef typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type exact_type;
00140
00141
00143 typedef abstract::generic_morpher<SrcType,
00144 exact_type> super_type;
00145
00147 typedef typename image_id<exact_type>::value_type value_type;
00148 typedef typename image_id<exact_type>::point_type point_type;
00149 typedef typename image_id<exact_type>::impl_type impl_type;
00150 enum { nbcomps = color_mute<oln_value_type(SrcType), N>::nbcomps };
00151
00153 subq_morpher(const SrcType &ima)
00154 : super_type(ima)
00155 {}
00156
00158 subq_morpher(const subq_morpher<SrcType, N>& r)
00159 : super_type(r.get_ima())
00160 {}
00161
00166 subq_morpher() {}
00167
00169 const value_type
00170 at(const point_type& p) const
00171 {
00172 value_type tmp;
00173 unsigned int i;
00174
00175 for (i = 0; i < nbcomps; i++)
00176 {
00177 tmp[i] = this->ima_[p][i] / ((ntg_max_val(ntg_comp_type(oln_value_type(SrcType))) + 1)
00178 / (ntg_max_val(ntg_comp_type(value_type)) + 1));
00179 }
00180 return tmp;
00181 }
00182
00184 const impl_type*
00185 impl() const
00186 {
00187 return ima_.impl();
00188 }
00189
00190 static std::string
00191 name()
00192 {
00193 return "subq_morpher<" + SrcType::name() + ">";
00194 }
00195
00196 };
00197
00221 template <unsigned S, class I>
00222 const subq_morpher<I, S> sqmorph(I &ima)
00223 {
00224 return subq_morpher<I, S>(ima);
00225 }
00226
00227 }
00228
00229 }
00230
00231
00232
00233
00234 #endif // !OLENA_MORPHER_SUBQ_MORPHER_HH
00235