|
channel_algorithm.hpp
Go to the documentation of this file.
10 /*************************************************************************************************/
40 //#pragma warning(disable: 4309) // disable truncation of constant value warning (using -1 to get the max value of an integral)
46 template <typename SrcChannelV, typename DstChannelV, bool SrcIsIntegral, bool DstIsIntegral> struct channel_converter_unsigned_impl;
47 template <typename SrcChannelV, typename DstChannelV, bool SrcIsGreater> struct channel_converter_unsigned_integral;
48 template <typename SrcChannelV, typename DstChannelV, bool SrcLessThanDst, bool SrcDivisible> struct channel_converter_unsigned_integral_impl;
49 template <typename SrcChannelV, typename DstChannelV, bool SrcLessThanDst, bool CannotFitInInteger> struct channel_converter_unsigned_integral_nondivisible;
57 struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,integer_traits< UnsignedIntegralChannel>::const_max> {};
125 : public detail::channel_converter_unsigned_impl<SrcChannelV,DstChannelV,is_integral<SrcChannelV>::value,is_integral<DstChannelV>::value> {};
129 template <typename T> struct channel_converter_unsigned<T,T> : public detail::identity<T> {};
143 (src - channel_traits<SrcChannelV>::min_value()) / channel_range<SrcChannelV>() * channel_range<DstChannelV>());
156 mpl::less<unsigned_integral_max_value<SrcChannelV>,unsigned_integral_max_value<DstChannelV> >::value > {};
166 !(unsigned_integral_max_value<DstChannelV>::value % unsigned_integral_max_value<SrcChannelV>::value) > {};
171 !(unsigned_integral_max_value<SrcChannelV>::value % unsigned_integral_max_value<DstChannelV>::value) > {};
185 static const integer_t mul = unsigned_integral_max_value<DstChannelV>::value / unsigned_integral_max_value<SrcChannelV>::value;
197 static const integer_t div = unsigned_integral_max_value<SrcChannelV>::value / unsigned_integral_max_value<DstChannelV>::value;
207 static const uintmax_t div = unsigned_integral_max_value<bits32>::value / unsigned_integral_max_value<DstChannelV>::value;
220 : public channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,SrcLessThanDst,
235 return DstChannelV(static_cast<dest_t>( src * unsigned_integral_max_value<DstChannelV>::value) / unsigned_integral_max_value<SrcChannelV>::value);
246 static const double mul = unsigned_integral_max_value<DstChannelV>::value / double(unsigned_integral_max_value<SrcChannelV>::value);
255 struct channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,false,CannotFit> {
266 return DstChannelV( static_cast< dst_integer_t >(( static_cast< double >( src + div2 ) / div )));
276 template <typename DstChannelV> struct channel_converter_unsigned<bits32f,DstChannelV> : public std::unary_function<bits32f,DstChannelV> {
280 return DstChannelV( static_cast< dst_integer_t >(x*channel_traits<DstChannelV>::max_value()+0.5f ));
284 template <typename SrcChannelV> struct channel_converter_unsigned<SrcChannelV,bits32f> : public std::unary_function<SrcChannelV,bits32f> {
285 bits32f operator()(SrcChannelV x) const { return bits32f(x/float(channel_traits<SrcChannelV>::max_value())); }
288 template <> struct channel_converter_unsigned<bits32f,bits32f> : public std::unary_function<bits32f,bits32f> {
294 template <> struct channel_converter_unsigned<bits32,bits32f> : public std::unary_function<bits32,bits32f> {
296 // unfortunately without an explicit check it is possible to get a round-off error. We must ensure that max_value of bits32 matches max_value of bits32f
302 template <> struct channel_converter_unsigned<bits32f,bits32> : public std::unary_function<bits32f,bits32> {
304 // unfortunately without an explicit check it is possible to get a round-off error. We must ensure that max_value of bits32 matches max_value of bits32f
314 // It is both a unary function, and a metafunction (thus requires the 'type' nested typedef, which equals result_type)
320 template <> struct channel_convert_to_unsigned<bits8s> : public std::unary_function<bits8s,bits8> {
325 template <> struct channel_convert_to_unsigned<bits16s> : public std::unary_function<bits16s,bits16> {
330 template <> struct channel_convert_to_unsigned<bits32s> : public std::unary_function<bits32s,bits32> {
337 // It is both a unary function, and a metafunction (thus requires the 'type' nested typedef, which equals result_type)
343 template <> struct channel_convert_from_unsigned<bits8s> : public std::unary_function<bits8,bits8s> {
348 template <> struct channel_convert_from_unsigned<bits16s> : public std::unary_function<bits16,bits16s> {
353 template <> struct channel_convert_from_unsigned<bits32s> : public std::unary_function<bits32,bits32s> {
367 typedef channel_converter_unsigned<typename to_unsigned::result_type, typename from_unsigned::argument_type> converter_unsigned;
374 template <typename DstChannel, typename SrcChannel> // Model ChannelConcept (could be channel references)
416 struct channel_multiplier_unsigned : public std::binary_function<ChannelValue,ChannelValue,ChannelValue> {
418 return ChannelValue(static_cast<typename base_channel_type<ChannelValue>::type>(a / double(channel_traits<ChannelValue>::max_value()) * b));
423 template<> struct channel_multiplier_unsigned<bits8> : public std::binary_function<bits8,bits8,bits8> {
424 bits8 operator()(bits8 a, bits8 b) const { return bits8(detail::div255(uint32_t(a) * uint32_t(b))); }
428 template<> struct channel_multiplier_unsigned<bits16> : public std::binary_function<bits16,bits16,bits16> {
429 bits16 operator()(bits16 a, bits16 b) const { return bits16((uint32_t(a) * uint32_t(b))/65535); }
433 template<> struct channel_multiplier_unsigned<bits32f> : public std::binary_function<bits32f,bits32f,bits32f> {
439 struct channel_multiplier : public std::binary_function<ChannelValue, ChannelValue, ChannelValue> {
channel_traits< Channel >::value_type channel_invert(Channel x) Default implementation. Provide overloads for performance. Definition: channel_algorithm.hpp:472 A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept. Definition: channel.hpp:155 channel_traits< DstChannel >::value_type channel_convert(const SrcChannel &src) Converting from one channel type to another. Definition: channel_algorithm.hpp:375 Channel utilities. channel_traits< Channel >::value_type channel_multiply(Channel a, Channel b) A function multiplying two channels. result = a * b / max_value. Definition: channel_algorithm.hpp:450 Same as channel_converter, except it takes the destination channel by reference, which allows us to m... Definition: channel_algorithm.hpp:384 A function object to multiply two channels. result = a * b / max_value. Definition: channel_algorithm.hpp:439 This is the default implementation. Performance specializatons are provided. Definition: channel_algorithm.hpp:416 Traits for channels. Contains the following members: Definition: channel.hpp:113 GIL configuration file. This is the default implementation. Performance specializatons are provided. Definition: channel_algorithm.hpp:46 A unary function object converting between channel types. Definition: channel_algorithm.hpp:363 Generated on Mon Mar 26 2018 16:26:15 for Generic Image Library by
1.8.6
|