simmplecoder / blazing-gil

A collection of image processing and computer vision algorithms in C++17 using Boost.GIL and Blaze linear algebra library
12 stars 2 forks source link

Implement as_matrix_channeled #14

Closed simmplecoder closed 4 years ago

simmplecoder commented 4 years ago

Movitvation

Having only single channel view conversions can be limiting quite a bit, and there are algorithms that work uniformly in both scalar and channeled mode.

Behavior

boost::gil::rgb8_image_t image = /*initialization*/;
auto view = boost::gil::view(image);

// the type of matrix_view is blaze::CustomMatrix<blaze::StaticVector<std::uint8_t, 3>>
auto matrix_view = flash::as_matrix_channeled(view);
matrix_view(0, 1) = {100, 100 ,100}; //reflected in view(1, 0)

view(2, 3) = boost::gil::rgb8_pixel_t(100, 100, 100); //reflected in matrix_view(3, 2)

Parameters

Parameters will be duplicated from as_matrix

Return value

Resulting CustomMatrix with StaticVector<ChannelType, num_channel> as elements.

simmplecoder commented 4 years ago

Due to diverging padding behavior between Blaze and GIL, the function is defined only on handful of types, namely the ones where sizeof(PixelType) == sizeof(blaze::StaticVector<ChannelType, num_channels, rowMajor unaligned, unpadded>). For the rest function will fail to compile, as it should.