34 #ifndef AIMS_UTILITY_CHANNEL_H 
   35 #define AIMS_UTILITY_CHANNEL_H 
   62 #define DECLARE_CHANNEL_SELECTOR_NAME() \ 
   63 class ChannelSelector \ 
   66 #define DECLARE_CHANNEL_SELECTOR_SPEC( T, U, C ) \ 
   69       ChannelSelector() {} \ 
   70       virtual ~ChannelSelector() {} \ 
   72       U select( const T& input, const uint8_t channel ); \ 
   73       void set( T& input, const uint8_t channel, const U& value ); \ 
   76       carto::ShallowConverter<U, C> channelconvset; \ 
   77       carto::ShallowConverter<C, U> channelconv; \ 
   78       carto::ShallowConverter<T, U> dataconv; \ 
   82 #define DECLARE_CHANNEL_SELECTOR_CLASS() \ 
   83 template <class T, class U, class C = byte > \ 
   84 DECLARE_CHANNEL_SELECTOR_NAME() \ 
   85 DECLARE_CHANNEL_SELECTOR_SPEC( T, U, C ) \ 
   88 #define DECLARE_CHANNEL_SELECTOR_SPECIALIZED( T ) \ 
   90 DECLARE_CHANNEL_SELECTOR_NAME() < T, U > \ 
   91 DECLARE_CHANNEL_SELECTOR_SPEC( T, U, byte ) \ 
  109 template <class T, class U>
 
  110 class ChannelSelector < 
carto::VolumeRef<T>, 
carto::VolumeRef<U> >
 
  121 template <
class T, 
class U, 
class C> 
inline 
  122 U ChannelSelector< T, U, C >::select( 
const T& input, 
const uint8_t )
 
  127 template <
class T, 
class U, 
class C> 
inline 
  128 void ChannelSelector< T, U, C >::set( T& input, 
const uint8_t, 
const U& value )
 
  133 template <
class U> 
inline 
  134 U ChannelSelector< AimsRGB, U >::select( 
const AimsRGB& input, 
const uint8_t channel )
 
  140       channelconv.convert( input.
red(), output );
 
  143       channelconv.convert( input.
green(), output );
 
  146       channelconv.convert( input.
blue(), output );
 
  149       dataconv.convert( input, output );
 
  154 template <
class U> 
inline 
  155 void ChannelSelector< AimsRGB, U >::set( 
AimsRGB& input, 
const uint8_t channel, 
const U& value )
 
  159       channelconvset.convert( value, input.
red() );
 
  162       channelconvset.convert( value, input.
green() );
 
  165       channelconvset.convert( value, input.
blue() );
 
  170 template <
class U> 
inline 
  171 U ChannelSelector< AimsRGBA, U >::select( 
const AimsRGBA& input, 
const uint8_t channel )
 
  177       channelconv.convert( input.
red(), output );
 
  180       channelconv.convert( input.
green(), output );
 
  183       channelconv.convert( input.
blue(), output );
 
  186       channelconv.convert( input.
alpha(), output );
 
  189       dataconv.convert( input, output );
 
  195 template <
class U> 
inline 
  196 void ChannelSelector< AimsRGBA, U >::set( 
AimsRGBA& input, 
const uint8_t channel, 
const U& value )
 
  200       channelconvset.convert( value, input.
red() );
 
  203       channelconvset.convert( value, input.
green() );
 
  206       channelconvset.convert( value, input.
blue() );
 
  209       channelconvset.convert( value, input.
alpha() );
 
  214 template <
class U> 
inline 
  215 U ChannelSelector< AimsHSV, U >::select( 
const AimsHSV& input, 
const uint8_t channel )
 
  221       channelconv.convert( input.
hue(), output );
 
  224       channelconv.convert( input.
saturation(), output );
 
  227       channelconv.convert( input.
value(), output );
 
  230       dataconv.convert( input, output );
 
  238 template <
class U> 
inline 
  239 void ChannelSelector< AimsHSV, U >::set( 
AimsHSV& input, 
const uint8_t channel, 
const U& value )
 
  243       channelconvset.convert( value, input.
hue() );
 
  246       channelconvset.convert( value, input.
saturation() );
 
  249       channelconvset.convert( value, input.
value() );
 
  256 template <
typename T, 
int D, 
typename U>
 
  273 template <
typename T, 
int D, 
typename U>
 
  276                                                  const uint8_t channel )
 
  280   channelconv.
convert( input[channel], output );
 
  284 template <
typename T, 
int D, 
typename U>
 
  286                                                   const uint8_t channel,
 
  289   channelconvset.convert( value, input[channel] );
 
  295 template<
class T, 
class U> 
inline 
  297 ChannelSelector< carto::VolumeRef<T>,
 
  299                                                 const uint8_t channel )
 
  301   ChannelSelector< T, U > selector;
 
  316   for( t=-b[6]; t<dt+b[6]; ++t )
 
  318       for( z=-b[4]; z<dz+b[4]; ++z )
 
  320           for( y=-b[2]; y<dy+b[2]; ++y )
 
  322               for( x=-b[0]; x<dx+b[0]; ++x )
 
  323                 output( x, y, z, t ) = selector.select( input( x, y, z, t ), channel );
 
  332 template<
class T, 
class U> 
inline 
  333 void ChannelSelector< carto::VolumeRef<T>,
 
  335                                                   const uint8_t channel,
 
  338   ChannelSelector<T, U> selector;
 
  346   for( t=0; t<dt; ++t )
 
  348       for( z=0; z<dz; ++z )
 
  350           for( y=0; y<dy; ++y )
 
  352               for( x=0; x<dx; ++x )
 
  353                  selector.set( input( x, y, z, t ),
 
  355                                value( x, y, z, t ) );
 
#define DECLARE_CHANNEL_SELECTOR_CLASS()
#define DECLARE_CHANNEL_SELECTOR_SPECIALIZED(T)
virtual ~ChannelSelector()
virtual ~ChannelSelector()
virtual void convert(const INP &in, OUTP &out) const
void setProperty(const std::string &, const T &)
std::vector< int > getBorders() const
virtual void copyHeaderFrom(const PropertySet &other)
const PropertySet & header() const
Volume< T >::Position4Di Position4Di
const uint8_t & hue() const
const uint8_t & saturation() const
const uint8_t & value() const
const uint8_t & green() const
const uint8_t & blue() const
const uint8_t & alpha() const
const uint8_t & red() const
const uint8_t & red() const
const uint8_t & blue() const
const uint8_t & green() const