channel_view.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // Copyright 2010 Fabien Castan, Christian Henning
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_EXTENSION_TOOLBOX_CHANNEL_VIEW_HPP
  9. #define BOOST_GIL_EXTENSION_TOOLBOX_CHANNEL_VIEW_HPP
  10. #include <boost/gil/image_view_factory.hpp>
  11. namespace boost {
  12. namespace gil {
  13. template < typename Channel
  14. , typename View
  15. >
  16. struct channel_type_to_index
  17. {
  18. static const int value = detail::type_to_index< typename color_space_type< View >::type // color (mpl::vector)
  19. , Channel // channel type
  20. >::value; //< index of the channel in the color (mpl::vector)
  21. };
  22. template< typename Channel
  23. , typename View
  24. >
  25. struct channel_view_type : public kth_channel_view_type< channel_type_to_index< Channel
  26. , View
  27. >::value
  28. , View
  29. >
  30. {
  31. static const int index = channel_type_to_index< Channel
  32. , View
  33. >::value;
  34. using parent_t = kth_channel_view_type<index, View>;
  35. using type = typename parent_t::type;
  36. static type make( const View& src )
  37. {
  38. return parent_t::make( src );
  39. }
  40. };
  41. /// \ingroup ImageViewTransformationsKthChannel
  42. template< typename Channel
  43. , typename View
  44. >
  45. typename channel_view_type< Channel
  46. , View
  47. >::type channel_view( const View& src )
  48. {
  49. return channel_view_type< Channel
  50. , View
  51. >::make( src );
  52. }
  53. } // namespace gil
  54. } // namespace boost
  55. #endif