c++ - 如何从 Boost::GIL View 类型中提取 channel 类型?

标签 c++ boost boost-gil

我找不到从 ImageView 中提取像素或 channel 类型的正确方法。在 gray8_view_t 的情况下,我希望将下面的 pod_t 定义为“unsigned char”。没有简单的 ViewType::pixel_t。这种类型在函数 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);
    }

最佳答案

ViewType::value_type应该与您预期的相似 ViewType::pixel_t .

然后,对于同类像素类型,channel_type<T>::type来自 HomogeneousPixelBasedConcept 应该导致您正在寻找的类型:

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
}

关于c++ - 如何从 Boost::GIL View 类型中提取 channel 类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6833769/

相关文章:

c++ - Boost::GIL bits8* 到 gray8_ptr_t 没有 reinterpret_cast?

c++ - std::set::find 与 std::find on std::set with const

c++ - 反向迭代流

c++ - boost 函数的Python方法

c++ - BOOST::Gil 用于图像处理

c++ - boost::gil 交错 View

c++ - 尝试递增 initializer_list.begin() 返回的迭代器时出现编译错误

c++ - ld:版本3无效(最大0)-添加符号错误:值错误

c++ - 将 openmp 与 odeint 和自适应步长一起使用

c++ - Boost三次Hermite插值 "requires template argument list"