TuttleOFX
1
|
00001 /* 00002 Copyright 2010 Fabien Castan, Christian Henning 00003 Use, modification and distribution are subject to the Boost Software License, 00004 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 00005 http://www.boost.org/LICENSE_1_0.txt). 00006 */ 00007 00008 /*************************************************************************************************/ 00009 00010 #ifndef _TERRY_CHANNEL_VIEW_HPP_ 00011 #define _TERRY_CHANNEL_VIEW_HPP_ 00012 00013 //////////////////////////////////////////////////////////////////////////////////////// 00014 /// \file channel_view.hpp 00015 /// \brief Helper to generate channel_view type. 00016 /// \author Fabien Castan, Christian Henning \n 00017 /// 00018 /// \date 2010 \n 00019 /// 00020 //////////////////////////////////////////////////////////////////////////////////////// 00021 00022 #include <boost/gil/pixel.hpp> 00023 #include <boost/gil/utilities.hpp> 00024 00025 namespace terry { 00026 00027 using namespace boost::gil; 00028 00029 template < typename Channel 00030 , typename View 00031 > 00032 struct channel_type_to_index 00033 { 00034 static const int value = boost::gil::detail::type_to_index< typename color_space_type< View >::type // color (mpl::vector) 00035 , Channel // channel type 00036 >::type::value; //< index of the channel in the color (mpl::vector) 00037 }; 00038 00039 template< typename Channel 00040 , typename View 00041 > 00042 struct channel_view_type : public kth_channel_view_type< channel_type_to_index< Channel 00043 , View 00044 >::value 00045 , View 00046 > 00047 { 00048 static const int index = channel_type_to_index< Channel 00049 , View 00050 >::value; 00051 00052 typedef kth_channel_view_type< index 00053 , View 00054 > parent_t; 00055 00056 typedef typename parent_t::type type; 00057 00058 00059 static type make( const View& src ) 00060 { 00061 return parent_t::make( src ); 00062 } 00063 }; 00064 00065 /// \ingroup ImageViewTransformationsKthChannel 00066 template< typename Channel 00067 , typename View 00068 > 00069 typename channel_view_type< Channel 00070 , View 00071 >::type channel_view( const View& src ) 00072 { 00073 return channel_view_type< Channel 00074 , View 00075 >::make( src ); 00076 } 00077 00078 } 00079 00080 #endif