Christian,

Thank you for this code. However, I would like the extracted channel to be the same pixel type as the original runtime image. I guess it is possible since if I write the extracted channel view without storing it in a variable (see my first post), it works fine. Here it is:

boost::gil::jpeg_read_image( input_filename , runtime_image );
boost::gil::jpeg_write_view( output_filename , boost::gil::nth_channel_view( view(runtime_image) , channel_index ) );

I just want to be as generic as possible and avoid "if ... else if ..." to get the right pixel type at runtime and thus perform the right dynamic_cast. Is it possible ?

Regards,

Olivier