Поддерживает ли boost :: gil 10-битные изображения?

Я пытаюсь прочитать 10-битные изображения из буфера и проанализировать их с помощью boost :: gil. Я заметил, что существует тип rgb8_image_t, тип gray8_image_t, но не могу найти тип gray10_image_t (что мне нужно). Это существует в Gil? Спасибо!

РЕДАКТИРОВАТЬ: При использовании этих typedefs:

// 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

Кто-нибудь знает, как это исправить? Благодарю.

1

Решение

Нет, но вы можете определить себя.

Поскольку тип вашего пикселя не выровнен по байту, вам необходимо объявить пиксель с выравниванием по битам и соответствующие типы:

Выровненные по битам пиксели (и изображения) являются более сложными, чем упакованные. Поскольку упакованные пиксели выровнены по байтам, мы можем использовать ссылку C ++ в качестве типа ссылки на упакованный пиксель и указатель C в качестве x_iterator на строку упакованных пикселей. Для выровненных по битам конструкций нам нужен специальный ссылочный прокси-класс (bit_aligned_pixel_reference) и класс итераторов (bit_aligned_pixel_iterator). Тип значения пикселей с выравниванием по битам — pack_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);
}
2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector