38 #ifndef OME_FILES_VARIANTPIXELBUFFER_H
39 #define OME_FILES_VARIANTPIXELBUFFER_H
43 #include <ome/files/PixelBuffer.h>
44 #include <ome/files/PixelProperties.h>
49 #include <boost/preprocessor.hpp>
98 typedef boost::mpl::vector<PixelProperties<::ome::xml::model::enums::PixelType::INT8>,
107 typedef boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::FLOAT>,
121 typedef std::shared_ptr<PixelBuffer<typename T::std_type>>
type;
144 typedef std::array<boost::multi_array_types::index, PixelBufferBase::dimensions>
indices_type;
176 template<
class ExtentList>
265 template<
class T,
class ExtentList>
298 # pragma GCC diagnostic push
299 # pragma GCC diagnostic ignored "-Wswitch-default"
302 #define OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE(maR, maProperty, maType) \
303 case ::ome::xml::model::enums::PixelType::maType: \
304 buf = makeBuffer<PixelProperties<::ome::xml::model::enums::PixelType::maType>::std_type>(extents, storage, pixeltype); \
318 template<
class ExtentList>
328 BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE, _, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
334 #undef OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE
336 #define OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE(maR, maProperty, maType) \
337 case ::ome::xml::model::enums::PixelType::maType: \
338 buf = makeBuffer<PixelProperties<::ome::xml::model::enums::PixelType::maType>::std_type>(range, storage, pixeltype); \
361 BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE, _, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
367 #undef OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE
370 # pragma GCC diagnostic pop
384 template<
class ExtentList>
454 const boost::multi_array_types::index *
465 const boost::multi_array_types::index *
478 template <
typename T>
620 template <
typename InputIterator>
622 assign(InputIterator begin,
635 template<
class charT,
class traits>
637 read(std::basic_istream<charT,traits>& stream);
649 template<
class charT,
class traits>
651 write(std::basic_ostream<charT,traits>& stream)
const;
676 throw std::runtime_error(
"Null pixel type");
686 template <
typename U>
690 throw std::runtime_error(
"Unsupported pixel type conversion for buffer");
709 throw std::runtime_error(
"Null pixel type");
719 template <
typename U>
723 throw std::runtime_error(
"Unsupported pixel type conversion for buffer");
728 template <
typename InputIterator>
743 begin(begin), end(end)
756 throw std::runtime_error(
"Null pixel type");
765 template <
typename T>
769 throw std::runtime_error(
"Unsupported pixel type conversion for assignment");
774 template<
class charT,
class traits>
778 std::basic_istream<charT,traits>&
stream;
794 template <
typename T>
799 throw std::runtime_error(
"Null pixel type");
805 template<
class charT,
class traits>
809 std::basic_ostream<charT,traits>&
stream;
825 template <
typename T>
830 throw std::runtime_error(
"Null pixel type");
865 std::array<VariantPixelBuffer::size_type, 9> dest_shape;
882 typename boost::multi_array_types::index_gen indices;
883 typedef boost::multi_array_types::index_range range;
884 destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(
subC,
subC+1)][range()][range()][range()]];
919 typename boost::multi_array_types::index_gen indices;
920 typedef boost::multi_array_types::index_range range;
921 destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(
subC,
subC+1)][range()][range()][range()]] = v->array();
929 inline typename PixelBuffer<T>::array_ref_type&
933 return boost::apply_visitor(v,
buffer)->array();
942 return boost::apply_visitor(v,
buffer)->array();
950 return boost::apply_visitor(v,
buffer)->data();
958 return boost::apply_visitor(v,
buffer)->data();
966 return boost::apply_visitor(v,
buffer)->origin();
976 template <
typename InputIterator>
982 boost::apply_visitor(v,
buffer);
985 template<
class charT,
class traits>
990 boost::apply_visitor(v,
buffer);
993 template<
class charT,
class traits>
998 boost::apply_visitor(v,
buffer);
1014 template<
class charT,
class traits>
1015 inline std::basic_istream<charT,traits>&
1016 operator>> (std::basic_istream<charT,traits>& is,
1030 template<
class charT,
class traits>
1031 inline std::basic_ostream<charT,traits>&
1032 operator<< (std::basic_ostream<charT,traits>& os,
1033 const ::ome::files::VariantPixelBuffer& buf)
1041 #endif // OME_FILES_VARIANTPIXELBUFFER_H
VariantPixelBufferWriteVisitor(std::basic_ostream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:816
static variant_buffer_type createBuffer(const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Create buffer from ranges (helper).
Definition: VariantPixelBuffer.h:353
boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type basic_pixel_types_view
Aggregate view of all numeric types.
Definition: VariantPixelBuffer.h:114
boost::multi_array_ref< value_type, dimensions > array_ref_type
Type for multi-dimensional pixel array view referencing external data.
Definition: PixelBuffer.h:246
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:892
const boost::multi_array_types::index * index_bases() const
Get the index bases of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:368
void read(std::basic_istream< charT, traits > &stream)
Read raw pixel data from a stream in physical storage order.
Definition: VariantPixelBuffer.h:987
void setBuffer(const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Set the buffer from ranges (internal storage).
Definition: VariantPixelBuffer.h:404
Properties of BIT pixels.
Definition: PixelProperties.h:299
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:734
Buffer for a specific pixel type.
Definition: PixelBuffer.h:235
bool operator!=(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for inequality.
Definition: VariantPixelBuffer.cpp:423
VariantPixelBuffer(const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Construct from extents (internal storage).
Definition: VariantPixelBuffer.h:178
static variant_buffer_type makeBuffer(const ExtentList &extents, const storage_order_type &storage,::ome::xml::model::enums::PixelType pixeltype)
Create buffer from extents (helper).
Definition: VariantPixelBuffer.h:267
size_type num_dimensions() const
Get the number of dimensions in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:347
boost::mpl::vector empty_types
Empty vector placeholder.
Definition: VariantPixelBuffer.h:128
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:58
void setBuffer(const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Set the buffer from extents (helper).
Definition: VariantPixelBuffer.h:386
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:228
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:732
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:785
Map a given PixelPropertiesType enum to the corresponding language types.
Definition: PixelProperties.h:60
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
Definition: VariantPixelBuffer.h:930
const boost::multi_array_types::index * strides() const
Get the strides of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:361
variant_buffer_type & vbuffer()
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:237
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:839
const size_type * shape() const
Get the shape of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:354
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:809
Properties of COMPLEXFLOAT pixels.
Definition: PixelProperties.h:334
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:161
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:841
boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::INT8 >, PixelProperties<::ome::xml::model::enums::PixelType::INT16 >, PixelProperties<::ome::xml::model::enums::PixelType::INT32 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT8 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT16 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT32 >, PixelProperties<::ome::xml::model::enums::PixelType::BIT > > integer_pixel_types
Integer pixel types.
Definition: VariantPixelBuffer.h:104
boost::mpl::transform_view< basic_pixel_types_view, make_buffer< boost::mpl::_1 > >::type pixel_buffer_types_view
Aggregate view of all buffer types.
Definition: VariantPixelBuffer.h:125
Properties of UINT16 pixels.
Definition: PixelProperties.h:207
PixelBuffer< T > * operator()(std::shared_ptr< PixelBuffer< T >> &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:673
Convert T into a buffer.
Definition: VariantPixelBuffer.h:118
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:894
const T * origin() const
Get the origin of the array.
Definition: VariantPixelBuffer.h:963
Properties of INT32 pixels.
Definition: PixelProperties.h:161
VariantPixelBuffer & operator=(const VariantPixelBuffer &rhs)
Assign a pixel buffer.
Definition: VariantPixelBuffer.cpp:410
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:836
boost::general_storage_order< dimensions > storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: PixelBuffer.h:120
const PixelBuffer< T > * operator()(const std::shared_ptr< PixelBuffer< T >> &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:706
Native endian.
Definition: Types.h:71
static storage_order_type make_storage_order(ome::xml::model::enums::DimensionOrder order, bool interleaved)
Generate storage ordering for a given dimension order.
Definition: PixelBuffer.cpp:54
MergeSubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:902
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:862
boost::mpl::insert_range< empty_types, boost::mpl::end< empty_types >::type, pixel_buffer_types_view >::type pixel_buffer_types
List of all pixel buffer types.
Definition: VariantPixelBuffer.h:131
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:775
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:889
bool valid() const
Check the buffer validity.
Definition: VariantPixelBuffer.cpp:326
VariantPixelBuffer(std::shared_ptr< PixelBuffer< T >> &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:221
size_type num_elements() const
Get the number of pixel elements in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:340
EndianType
Endianness.
Definition: Types.h:67
VariantPixelBuffer(const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Construct from ranges (internal storage).
Definition: VariantPixelBuffer.h:196
const variant_buffer_type & vbuffer() const
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:248
PixelProperties<::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
Raw pixel type used in public interfaces.
Definition: VariantPixelBuffer.h:138
Properties of INT16 pixels.
Definition: PixelProperties.h:138
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:849
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:696
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:742
void operator()(T &v) const
Read data into specific PixelBuffer type.
Definition: VariantPixelBuffer.h:796
boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::FLOAT >, PixelProperties<::ome::xml::model::enums::PixelType::DOUBLE >, PixelProperties<::ome::xml::model::enums::PixelType::COMPLEXFLOAT >, PixelProperties<::ome::xml::model::enums::PixelType::COMPLEXDOUBLE > > float_pixel_types
Floating-point pixel types.
Definition: VariantPixelBuffer.h:110
void operator()(std::shared_ptr< PixelBuffer< typename std::iterator_traits< InputIterator >::value_type >> &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:753
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:995
void operator()(const T &v) const
Write data from specific PixelBuffer type.
Definition: VariantPixelBuffer.h:827
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:915
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:729
EndianType endianType() const
Get the endianness of the pixel type stored in the buffer.
Definition: VariantPixelBuffer.cpp:389
static variant_buffer_type makeBuffer(const range_type &range, const storage_order_type &storage,::ome::xml::model::enums::PixelType pixeltype)
Create buffer from ranges (helper).
Definition: VariantPixelBuffer.h:287
variant_buffer_type buffer
Pixel storage.
Definition: VariantPixelBuffer.h:655
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:806
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:778
Properties of UINT32 pixels.
Definition: PixelProperties.h:230
boost::detail::multi_array::extent_gen< dimensions > range_type
Extent range type.
Definition: PixelBuffer.h:123
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:663
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:150
static const uint16_t dimensions
Total number of supported dimensions.
Definition: PixelBuffer.h:107
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
static variant_buffer_type createBuffer(const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Create buffer from extents (internal storage).
Definition: VariantPixelBuffer.h:320
Properties of UINT8 pixels.
Definition: PixelProperties.h:184
const storage_order_type & storage_order() const
Get the array storage order.
Definition: VariantPixelBuffer.cpp:375
static storage_order_type default_storage_order()
Generate default storage ordering.
Definition: PixelBuffer.cpp:133
raw_type * data()
Get raw buffered data.
Definition: VariantPixelBuffer.cpp:396
std::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:121
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:78
Properties of DOUBLE pixels.
Definition: PixelProperties.h:276
boost::multi_array_types::size_type size_type
Size type.
Definition: VariantPixelBuffer.h:141
bool managed() const
Check if the buffer is internally managed.
Definition: VariantPixelBuffer.cpp:333
void assign(InputIterator begin, InputIterator end)
Assign pixel values.
Definition: VariantPixelBuffer.h:978
boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
Buffer type, allowing assignment of all buffer types.
Definition: VariantPixelBuffer.h:135
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: VariantPixelBuffer.h:147
std::array< boost::multi_array_types::index, PixelBufferBase::dimensions > indices_type
Type used to index all dimensions in public interfaces.
Definition: VariantPixelBuffer.h:144
::ome::xml::model::enums::PixelType pixelType() const
Get the type of pixels stored in the buffer.
Definition: VariantPixelBuffer.cpp:382
Properties of COMPLEXDOUBLE pixels.
Definition: PixelProperties.h:357
Logical sub-channel (typically used for RGB channel sub-components) (S).
Definition: PixelBuffer.h:85