Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] How can I in-place convert some part of view to grayscale.
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-04-10 15:48:22


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net