
A good example of using kth_channel_view is this:
rgb8_image_t img( 100, 100 ); typedef typename kth_channel_view_type< 0, const rgb8_view_t>::type view_t; view_t first = kth_channel_view<0>( const_view( img ));
Another interesting possibility is: typedef kth_channel_view_type< 0, const rgb8_view_t> KthChannelView; typename KthChannelView::type first = KthChannelView::make( const_view(img) ); It can be a good thing to directly use channel type, like this: typedef channel_view_type< red_t, const rgb8_view_t>::type view_t; view_t first = channel_view<red_t>( const_view( img )); I have written some code to do that, based on kth_channel_view_type. It's maybe intersting to include in gil. Regards, Fabien namespace boost { namespace gil { template <typename Channel, typename View> struct channel_type_to_index { static const int value = gil::detail::type_to_index< typename color_space_type<View>::type, // color (mpl::vector) Channel // channel type >::type::value; //< index of the channel in the color (mpl::vector) }; template <typename Channel, typename View> struct channel_view_type : public kth_channel_view_type<channel_type_to_index<Channel,View>::value, View> { static const int index = channel_type_to_index<Channel,View>::value; typedef kth_channel_view_type<index, View> parent_t; typedef typename parent_t::type type; static type make(const View& src) { return parent_t::make(src); } }; /// \ingroup ImageViewTransformationsKthChannel template <typename Channel, typename View> typename channel_view_type<Channel,View>::type channel_view(const View& src) { return channel_view_type<Channel,View>::make(src); } }}