[GIL] How can I in-place convert some part of view to grayscale.
Hi,
I have a rgb8_image_t::view_t view, and I want to convert some part of it to
grayscale within its region,
for example: 0,0,100,100 (x,y,width,height)
How can I do this?
I try to do this but it can't be compiled.
typedef boost::gil::pixel<
typename boost::gil::channel_type<
boost::gil::rgb8_image_t::view_t>::type,
boost::gil::gray_layout_t> gray_pixel_t;
boost::gil::copy_pixels(
boost::gil::color_converted_view
Mhmm, that's weird. For a quick fix the following is working: typedef rgb8_image_t image_src_t; typedef gray8_image_t image_dst_t; image_src_t dst( 100, 100 ); image_dst_t src( 100, 100 ); copy_pixels( color_converted_view< image_dst_t::value_type >( subimage_view( view( src ) , 0 , 0 , 100 , 100 )) , color_converted_view< image_dst_t::value_type >( view( dst )) ); I'll get back to you once I understand what's going on. Regards, Christian
Hi, you should probably use "copy_and_convert_pixels" instead of "copy_pixels". Your code will then compile. I think copy_pixels is meant for compatible color spaces. copy_and_convert_pixels( subimage_view( view( src ),0, 0, 100, 100 ) , subimage_view( view( dst ),0, 0, 100, 100 ) ); But still, I think there is a bug. Consider the following code: typedef rgb8_image_t image_src_t; typedef gray8_image_t image_dst_t; image_src_t dst( 100, 100 ); image_dst_t src( 100, 100 ); copy_pixels( color_converted_view< image_dst_t::value_type >( subimage_view( view( src ) , 0 , 0 , 100 , 100 )) , color_converted_view< image_dst_t::value_type >( view( dst )) ); This code bombs in static_copy since semantic_at_c<1>(p2) is not defined for gray_pixel_t. But when interchanging the typedef: typedef gray8_image_t image_src_t; typedef rgb8_image_t image_dst_t; it now works. Again, the following doesn't work: typedef rgba8_image_t image_src_t; typedef rgb8_image_t image_dst_t; But this does: typedef rgb8_image_t image_src_t; typedef rgba8_image_t image_dst_t; Basically if the dst image type has less channels the code wont compile. Regards, Christian
participants (2)
-
blp330
-
Christian Henning