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 #ifndef MLN_WORLD_RGB_INVERT_HH
00027 # define MLN_WORLD_RGB_INVERT_HH
00028
00034
00035 # include <mln/core/concept/image.hh>
00036 # include <mln/trait/value_.hh>
00037 # include <mln/value/rgb.hh>
00038
00039
00040 # include <mln/world/rgb/invert.spe.hh>
00041
00042
00043 namespace mln
00044 {
00045
00046 namespace world
00047 {
00048
00049 namespace rgb
00050 {
00051
00053
00067 template <typename I>
00068 mln_concrete(I) invert(const Image<I>& input);
00069
00070
00072
00085 template <typename I>
00086 void invert_inplace(Image<I>& input);
00087
00088
00089 # ifndef MLN_INCLUDE_ONLY
00090
00091 namespace impl
00092 {
00093
00094 namespace generic
00095 {
00096
00097 template <typename I, typename O>
00098 inline
00099 void invert(const Image<I>& input_, Image<O>& output_)
00100 {
00101 trace::entering("world::rgb::impl::generic::invert");
00102
00103 const I& input = exact(input_);
00104 O& output = exact(output_);
00105
00106 mln_precondition(input.is_valid());
00107 mln_precondition(output.is_valid());
00108
00109 typedef mln_value(I) V;
00110 mln_piter(I) p(input.domain());
00111 for_all(p)
00112 output(p) = mln_min(V) + (mln_max(V) - input(p));
00113
00114 trace::exiting("world::rgb::impl::generic::invert");
00115 }
00116
00117 }
00118
00119
00120 }
00121
00122
00123
00124
00125
00126 namespace internal
00127 {
00128
00129 template <typename I, typename O>
00130 inline
00131 void
00132 invert_dispatch(trait::image::speed::any, const mln_value(I)&,
00133 const I& input, O& output)
00134 {
00135
00136 mlc_abort(I)::check();
00137 }
00138
00139
00140 template <typename I, typename O, unsigned n>
00141 inline
00142 void
00143 invert_dispatch(trait::image::speed::any, const value::rgb<n>&,
00144 const I& input, O& output)
00145 {
00146 impl::invert_rgb(input, output);
00147 }
00148
00149 template <typename I, typename O, unsigned n>
00150 inline
00151 void
00152 invert_dispatch(trait::image::speed::fastest, const value::rgb<n>&,
00153 const I& input, O& output)
00154 {
00155 impl::invert_rgb_fastest(input, output);
00156 }
00157
00158
00159 template <typename I, typename O>
00160 inline
00161 void
00162 invert_dispatch(const Image<I>& input, Image<O>& output)
00163 {
00164 typedef mln_value(I) V;
00165 invert_dispatch(mln_trait_image_speed(I)(), V(),
00166 exact(input), exact(output));
00167
00168 }
00169
00170
00171 }
00172
00173
00174
00175
00176
00177
00178 template <typename I>
00179 inline
00180 mln_concrete(I) invert(const Image<I>& input)
00181 {
00182 trace::entering("world::rgb::invert");
00183
00184 mln_precondition(exact(input).is_valid());
00185
00186 mln_concrete(I) output;
00187 initialize(output, input);
00188 internal::invert_dispatch(input, output);
00189
00190 trace::exiting("world::rgb::invert");
00191 return output;
00192 }
00193
00194 template <typename I>
00195 inline
00196 void invert_inplace(Image<I>& input)
00197 {
00198 trace::entering("world::rgb::invert_inplace");
00199
00200 mln_precondition(exact(input).is_valid());
00201
00202 internal::invert_dispatch(input, input);
00203
00204 trace::exiting("world::rgb::invert_inplace");
00205 }
00206
00207 # endif // ! MLN_INCLUDE_ONLY
00208
00209 }
00210
00211 }
00212
00213 }
00214
00215
00216 #endif // ! MLN_WORLD_RGB_INVERT_HH