#include #include //#include #include #include void usage() { std::cout << "Usage:\n"; std::cout << "\t GIL_extract_channel \n"; } namespace boost { namespace gil { /// Extension a GIL pour gerer les pixels "double" ... typedef pixel< double, boost::gil::gray_layout_t > gray64_pixel_t; typedef image< gray64_pixel_t, false > gray64_image_t; typedef image< gray64_pixel_t, true > gray64_planar_image_t; //typedef image_view< gray64_pixel_t > gray64_view_t; } } int main ( int argc , char **argv) { typedef boost::mpl::vector< boost::gil::gray8_image_t, boost::gil::gray16_image_t, boost::gil::gray32_image_t, //boost::gil::gray64_image_t, boost::gil::rgb8_image_t, boost::gil::rgb16_image_t, boost::gil::rgb32_image_t > my_img_types; typedef boost::mpl::vector< boost::gil::gray8_view_t, boost::gil::gray16_view_t, boost::gil::gray32_view_t, //boost::gil::gray64_view_t, boost::gil::rgb8_view_t, boost::gil::rgb16_view_t, boost::gil::rgb32_view_t > my_view_types; if ( argc < 4 ) { usage(); return 1; } std::string input_filename( argv[1] ); std::string output_filename( argv[3] ); int channel_index; try { channel_index = boost::lexical_cast( argv[2] ); } catch( boost::bad_lexical_cast &e) { std::cout << "bad_lexical_cast exception : " << e.what() << std::endl; return 1; } boost::gil::any_image runtime_image; boost::gil::any_image_view runtime_view; try { boost::gil::jpeg_read_image( input_filename , runtime_image ); runtime_view = boost::gil::nth_channel_view( const_view(runtime_image) , channel_index ); boost::gil::jpeg_write_view( output_filename , runtime_view ); } catch( std::exception &e ) { std::cout << e.what() << std::endl; return 1; } return 0; }