2011-07-26 54 views
2

我找不到從圖像視圖中提取像素或通道類型的正確方法。我期待在gray8_view_t的情況下將pod_t定義爲'unsigned char'。沒有簡單的ViewType :: pixel_t。 PixelFoo函數中這種類型的正確定義是什麼?如何從Boost :: GIL視圖類型中提取通道類型?

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); 
    } 

回答

0

ViewType::value_type應該類似於您所期望的是ViewType::pixel_t

然後,對於同質像素類型,從HomogeneousPixelBasedConcept的channel_type<T>::type應該引起你正在尋找的類型:

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 
} 
+0

如何簡單。謝謝。 – totowtwo

0

這是我目前的工作周圍,但我敢肯定有一個提供方法來獲得我需要的類型。

template<class DestView> 
struct view_traits; 
template<> 
struct view_traits<gray8_view_t> { 
    typedef bits8 channel_t; 
}; 
template<> 
struct view_traits<gray16_view_t> { 
    typedef bits16 channel_t; 
}; 
template<> 
struct view_traits<gray64f_view_t> { 
    typedef double channel_t; 
}; 
相關問題