Type conversion with Boost Generic Image Library

310 Views Asked by At

I currently have an image of the type boost::gil::rgb8c_view_t. I need to pass it to a function with this prototype:

void function(const boost::gil::rgb8c_view_t& input, const int index, const boost::gil::rgb8c_view_t::view_t &output)

I have created an output image by using the following syntax:

boost::gil::rgb8c_view_t::view_t output(input._dynamic_cast<boost::gil::rgb8c_view_t::view_t>());

At this point, the compiler accepts the image output as input for the function. However, I need the image back to the boost::gil::rgb8c_view_t type. The question is:

  • Is it a correct way to allocate the image output?
  • How do I transform it back to the type boost::gil::rgb8c_view_t?

Thank you in advance, Néstor

1

There are 1 best solutions below

0
On

I am not sure if I understand your question correctly (see comments above), but to create an output image with the same size as your input image, you could use a call like the following:

boost::gil::rgb8_image_t output_image(input.dimensions());

And get a mutable view like this:

boost::gil::rgb8_view_t boost::gil::view(output_image);

Of course you can also get a constant/immutable view like this:

boost::gil::rgb8c_view_t boost::gil::const_view(output_image);