void fast_rgb_to_luv(const boost::gil::rgb8c_view_t &rgb_view,
                     const boost::gil::dev3n8_planar_view_t &luv_view)
{

    using namespace boost::gil;

    if(rgb_view.dimensions() != luv_view.dimensions())
    {
        throw std::invalid_argument("rgb_to_luv expects views of the same dimensions");
    }

#pragma omp parallel for
    for(size_t row=0; row < static_cast<size_t>(rgb_view.height()); row +=1)
    {
        rgb8c_view_t::x_iterator rgb_row_it = rgb_view.row_begin(row);
        dev3n8_planar_view_t::x_iterator luv_row_it = luv_view.row_begin(row);

        for(size_t col=0; col < static_cast<size_t>(rgb_view.width());
            col +=1, ++rgb_row_it, ++luv_row_it)
        {
            (*luv_row_it) = rgb_to_luv(*rgb_row_it);

        } // end of "for each column"
    } // end of "for each row"

    return;
}
Пример #2
0
void ObjectsDetectionLibGui::set_right_input(boost::gil::rgb8c_view_t &view)
{
    input_right_view = view;

    if(view.dimensions() != screen_right_view.dimensions())
    {
        printf("ObjectsDetectionLibGui was initialized with (%zi, %zi), but received an image of size (%zi, %zi)\n",
               screen_left_view.width(), screen_right_view.height(),
               view.width(), view.height());
        throw std::invalid_argument("ObjectsDetectionLibGui does not support changes in the input image size");
    }
    return;
}
Пример #3
0
bool GilViewToHBitmap(SHARED_HBITMAP &result, const boost::gil::rgb8c_view_t &view) {
    BOOST_ASSERT(view.height() > 0);
    BOOST_ASSERT(view.width() > 0);
    BOOST_ASSERT(view.height() <= UINT_MAX);
    BOOST_ASSERT(view.width() <= UINT_MAX);
    const unsigned row = view.width() * view.num_channels();
    BOOST_ASSERT(row * view.height() <= UINT_MAX);
    std::vector<unsigned char> buffer(row * static_cast<unsigned int>(view.height()));
    std::vector<unsigned char *> ptr_list(static_cast<unsigned int>(view.height()));
    for(unsigned int i = 0; i < static_cast<unsigned int>(view.height()); i++) {
        ptr_list[i] = &buffer[row * i];
        std::copy(view.row_begin(static_cast<int>(i)), view.row_end(static_cast<int>(i)), reinterpret_cast<boost::gil::rgb8c_view_t::value_type *>(ptr_list[i]));
    }
    if(!CreateHBitmap(result, static_cast<unsigned int>(view.width()), static_cast<unsigned int>(view.height()), view.num_channels(), &ptr_list.front())) {
        return false;
    }
    return true;
}