heterogeneous pixel

  • Anonymous

    Anonymous - 2012-08-08

    How would one create a pixel whose channels are different data types using GIL? I ask because I would like to create and manipulate Y'CbCr images where the the 8-bit Y' channel ranges from 16 to 235 and the 8-bit Cb and Cr channels range from 16 to 240.

  • Anonymous

    Anonymous - 2012-08-08

    You can do something like this.

    #include <boost\gil\gil_all.hpp>

    using namespace boost;
    using namespace gil;

    struct y_values_min { static unsigned char apply() { return 16; } };
    struct y_values_max { static unsigned char apply() { return 235; } };

    struct c_values_min { static unsigned char apply() { return 16; } };
    struct c_values_max { static unsigned char apply() { return 240; } };

    int _tmain(int argc, _TCHAR* argv)
        typedef scoped_channel_value<unsigned char, y_values_min, y_values_max> y_channel_t;
        typedef scoped_channel_value<unsigned char, c_values_min, c_values_max> c_channel_t;

        //color space
        typedef mpl::vector3< y_channel_t, c_channel_t, c_channel_t> ycbcr_cs_t;

        typedef layout<ycbcr_cs_t> ycbcr_layout_t;
        typedef pixel< double, ycbcr_layout_t > ycbcr_pixel_t;

        typedef image< ycbcr_pixel_t > ycbcr_image_t;

    return 0;

    Let me know,

  • Anonymous

    Anonymous - 2012-09-13

    Thanks Christian.  I was concerned that I would have to create a heterogeneous_color_base to make this work, but your solution works fine. I had to specialize the bits32f and luma and chroma channel conversions, but that a small price to pay.  Thanks again.



Log in to post a comment.