Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract channel type from Boost::GIL view type?

I cant find the correct way to extract the pixel or channel type from an image view. I'm looking to define pod_t below to be 'unsigned char' in the case of gray8_view_t. There is no simple ViewType::pixel_t. What is the proper definition of this type in function PixelFoo?

    template<class ViewType> 
    void PixelFoo(ViewType v)
    {
        typedef typename ViewType::x_iterator::value_type::channel_t pod_t;
        pod_t maxVal = channel_traits<pod_t>::max_value();
        pod_t podVal = v(0, 0); //expect error with emptyView
    }
    void PixelBar()
    {
        gray8_view_t emptyView;
        PixelFoo(emptyView);
    }
like image 614
totowtwo Avatar asked Nov 21 '25 09:11

totowtwo


1 Answers

ViewType::value_type should be similar to what you expected to be ViewType::pixel_t.

Then, for homogeneous pixel types, the channel_type<T>::type from HomogeneousPixelBasedConcept should lead to the type you are looking for:

template<class ViewType> 
void PixelFoo(ViewType v)
{
    typedef typename boost::gil::channel_type<typename ViewType::value_type>::type pod_t;
    pod_t maxVal = channel_traits<pod_t>::max_value();
    pod_t podVal = v(0, 0); //expect error with emptyView
}
like image 179
OK. Avatar answered Nov 22 '25 23:11

OK.