boost::gil支持10位图像吗
Does boost::gil support 10 bit images?
我正在尝试从缓冲区读取10位图像,并使用boost::gil进行分析。我注意到存在一个rgb8_image_t类型,一个gray8_image_t类型,但找不到gray10_image_tt类型(这正是我所需要的(。这在吉尔存在吗?谢谢
编辑:使用这些类型时defs:
// reference type
typedef boost::gil::bit_aligned_pixel_reference<unsigned short, boost::mpl::vector1_c<unsigned, 10>, boost::gil::gray_layout_t, true> gray10_ref_t;
// iterator type
typedef boost::gil::bit_aligned_pixel_iterator<gray10_ref_t> gray10_ptr_t;
// pixel type
typedef std::iterator_traits<gray10_ptr_t>::value_type gray10_pixel_t;
// pixel storage to read, contains 3 10-bit gray pixels, all with value of 1 as per the following layout
// spaces show byte breaks, bars show pixel breaks, lsb first
// 10000000 00|100000 0000|1000 00000000
std::uint8_t data[4] = { 0x01, 0x04, 0x10, 0x00 };
// an iterator to the start of the storage
gray10_ptr_t p(&data[0], 0);
// check the expected pixel values
assert(p[0] == 0x01);
assert(p[1] == 0x01);
assert(p[2] == 0x01);
我在编译时得到以下错误:
untitled.cpp:17:6: error: ‘uint8_t’ in namespace ‘std’ does not name a type
std::uint8_t data[4] = { 0x01, 0x04, 0x10, 0x00 };
^
untitled.cpp:20:17: error: ‘data’ was not declared in this scope
gray10_ptr_t p(&data[0], 0);
^
In file included from /usr/include/boost/predef/detail/_cassert.h:14:0,
from /usr/include/boost/predef/library/c/_prefix.h:11,
from /usr/include/boost/predef/library/c.h:11,
from /usr/include/boost/predef/library.h:11,
from /usr/include/boost/predef.h:14,
from /usr/include/boost/smart_ptr/detail/yield_k.hpp:28,
from /usr/include/boost/smart_ptr/detail/spinlock_sync.hpp:18,
from /usr/include/boost/smart_ptr/detail/spinlock.hpp:50,
from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:34,
from /usr/include/boost/shared_ptr.hpp:17,
from /usr/include/boost/gil/extension/io/io_error.hpp:23,
from /usr/include/boost/gil/extension/io/tiff_io.hpp:29,
from untitled.cpp:1:
untitled.cpp:23:13: error: expected ‘)’ before ‘==’ token
assert(p[0] == 0x01);
^
untitled.cpp:23:13: error: expected ‘)’ before ‘==’ token
untitled.cpp:24:13: error: expected ‘)’ before ‘==’ token
assert(p[1] == 0x01);
^
untitled.cpp:24:13: error: expected ‘)’ before ‘==’ token
untitled.cpp:25:13: error: expected ‘)’ before ‘==’ token
assert(p[2] == 0x01);
^
untitled.cpp:25:13: error: expected ‘)’ before ‘==’ token
有人知道如何修理这些吗?谢谢
没有,但您可以自己定义一个。
由于你的像素类型不是字节对齐的,你需要声明一个位对齐的像素和相关类型:
位对齐像素(和图像(比压缩像素更复杂。由于压缩像素是字节对齐的,我们可以使用C++引用作为压缩像素的引用类型,并使用C指针作为一行压缩像素上的x_迭代器。对于位对齐结构,我们需要一个特殊的引用代理类(bit_aligned_pixel_reference(和迭代器类(bit_aligned_pixel_iterator(。位对齐像素的值类型是packed_pixel。
一个工作示例:
#include <boost/gil.hpp>
#include <boost/mpl/vector.hpp>
#include <cstdint>
int main()
{
// reference type
using gray10_ref_t = boost::gil::bit_aligned_pixel_reference<unsigned short, boost::mpl::vector1_c<unsigned, 10>, boost::gil::gray_layout_t, true>;
// iterator type
using gray10_ptr_t = boost::gil::bit_aligned_pixel_iterator<gray10_ref_t>;
// pixel type
using gray10_pixel_t = std::iterator_traits<gray10_ptr_t>::value_type;
// pixel storage to read, contains 3 10-bit gray pixels, all with value of 1 as per the following layout
// spaces show byte breaks, bars show pixel breaks, lsb first
// 10000000 00|100000 0000|1000 00000000
std::uint8_t data[4] = { 0x01, 0x04, 0x10, 0x00 };
// an iterator to the start of the storage
gray10_ptr_t p(&data[0], 0);
// check the expected pixel values
assert(p[0] == 0x01);
assert(p[1] == 0x01);
assert(p[2] == 0x01);
}
相关文章:
- 16 位到 10 位转换代码说明
- boost::gil支持10位图像吗
- 将 10 位值写入 char 数组
- C 正则是从字符串中提取所有可能的10位数字
- 无需使用循环,就将ISBN-10的前9位数字读取为字符串并计算第10位数字
- Qimage :: Pixel函数的10位输出特别是指的是什么
- 检测显示屏上的 10 位颜色支持
- 在 c++ 中不能将超过 10 位数字放入一个变量中
- 为什么我的代码从 10 位数字开始不起作用C++
- bignumber.h arduino如何解析大于10位数字的数字
- 唯一的 10 位序列 ID - 200 个 ID/秒
- 如何宽色域,从8位转换到10位
- 在 C/C++ 中创建 10 位数据类型
- 为什么此函数的计数不会超过 10 位?
- C++ 中的 10 位或 12 位字段数据类型
- 如何在C++中计算10位小数精度的双变量
- 以毫秒为单位的时间戳给了我 10 位C++数字
- 在未对齐的字节边界上高效打包 10 位数据
- Htoi的10位输出不正确
- 图像处理:位图旋转(c++ /GDI+)