38 #ifndef OME_FILES_VARIANTPIXELBUFFER_H 39 #define OME_FILES_VARIANTPIXELBUFFER_H 41 #include <ome/files/PixelBuffer.h> 42 #include <ome/files/PixelProperties.h> 95 typedef boost::mpl::vector<PixelProperties< ::ome::xml::model::enums::PixelType::INT8>,
104 typedef boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>,
118 typedef ome::compat::shared_ptr<PixelBuffer<typename T::std_type> >
type;
128 typedef boost::mpl::insert_range<empty_types, boost::mpl::end<empty_types>::type, pixel_buffer_types_view>
::type pixel_buffer_types;
141 typedef ome::compat::array<boost::multi_array_types::index, PixelBufferBase::dimensions>
indices_type;
173 template<
class ExtentList>
244 const variant_buffer_type&
262 template<
class T,
class ExtentList>
263 static variant_buffer_type
265 const storage_order_type& storage,
283 static variant_buffer_type
285 const storage_order_type& storage,
295 # pragma GCC diagnostic push 296 # pragma GCC diagnostic ignored "-Wswitch-default" 299 #define OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE(maR, maProperty, maType) \ 300 case ::ome::xml::model::enums::PixelType::maType: \ 301 buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::maType>::std_type>(extents, storage, pixeltype); \ 315 template<
class ExtentList>
316 static variant_buffer_type
321 variant_buffer_type buf;
325 BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE, size, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
331 #undef OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE 333 #define OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE(maR, maProperty, maType) \ 334 case ::ome::xml::model::enums::PixelType::maType: \ 335 buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::maType>::std_type>(range, storage, pixeltype); \ 349 static variant_buffer_type
354 variant_buffer_type buf;
358 BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE, size, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
364 #undef OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE 367 # pragma GCC diagnostic pop 381 template<
class ExtentList>
447 const boost::multi_array_types::index *
458 const boost::multi_array_types::index *
471 template <
typename T>
480 const storage_order_type&
609 template <
typename InputIterator>
611 assign(InputIterator begin,
624 template<
class charT,
class traits>
626 read(std::basic_istream<charT,traits>& stream);
638 template<
class charT,
class traits>
640 write(std::basic_ostream<charT,traits>& stream)
const;
665 throw std::runtime_error(
"Null pixel type");
675 template <
typename U>
677 operator() (U& )
const 679 throw std::runtime_error(
"Unsupported pixel type conversion for buffer");
698 throw std::runtime_error(
"Null pixel type");
708 template <
typename U>
710 operator() (U& )
const 712 throw std::runtime_error(
"Unsupported pixel type conversion for buffer");
717 template <
typename InputIterator>
732 begin(begin), end(end)
742 operator() (ome::compat::shared_ptr<
PixelBuffer<
typename std::iterator_traits<InputIterator>::value_type> >& v)
const 745 throw std::runtime_error(
"Null pixel type");
746 v->array().assign(begin, end);
754 template <
typename T>
756 operator() (T& )
const 758 throw std::runtime_error(
"Unsupported pixel type conversion for assignment");
763 template<
class charT,
class traits>
767 std::basic_istream<charT,traits>&
stream;
783 template <
typename T>
785 operator() (T& v)
const 788 throw std::runtime_error(
"Null pixel type");
794 template<
class charT,
class traits>
798 std::basic_ostream<charT,traits>&
stream;
814 template <
typename T>
816 operator() (
const T& v)
const 819 throw std::runtime_error(
"Null pixel type");
854 ome::compat::array<VariantPixelBuffer::size_type, 9> dest_shape;
867 dest.
setBuffer(dest_shape, v->pixelType(), order);
869 T& destbuf = boost::get<T>(dest.
vbuffer());
871 typename boost::multi_array_types::index_gen indices;
872 typedef boost::multi_array_types::index_range range;
873 destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]];
906 T& destbuf = boost::get<T>(dest.
vbuffer());
908 typename boost::multi_array_types::index_gen indices;
909 typedef boost::multi_array_types::index_range range;
910 destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]] = v->array();
922 return boost::apply_visitor(v, buffer).array();
931 return boost::apply_visitor(v, buffer).array();
939 return boost::apply_visitor(v, buffer).data();
947 return boost::apply_visitor(v, buffer).data();
955 return boost::apply_visitor(v, buffer).origin();
965 template <
typename InputIterator>
971 boost::apply_visitor(v, buffer);
974 template<
class charT,
class traits>
979 boost::apply_visitor(v, buffer);
982 template<
class charT,
class traits>
987 boost::apply_visitor(v, buffer);
1003 template<
class charT,
class traits>
1004 inline std::basic_istream<charT,traits>&
1005 operator>> (std::basic_istream<charT,traits>& is,
1019 template<
class charT,
class traits>
1020 inline std::basic_ostream<charT,traits>&
1021 operator<< (std::basic_ostream<charT,traits>& os,
1022 const ::ome::files::VariantPixelBuffer& buf)
1030 #endif // OME_FILES_VARIANTPIXELBUFFER_H VariantPixelBufferWriteVisitor(std::basic_ostream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:805
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:350
boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type basic_pixel_types_view
Aggregate view of all numeric types.
Definition: VariantPixelBuffer.h:111
boost::multi_array_ref< value_type, dimensions > array_ref_type
Type for multi-dimensional pixel array view referencing external data.
Definition: PixelBuffer.h:247
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:881
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:976
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:401
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:723
Buffer for a specific pixel type.
Definition: PixelBuffer.h:236
bool operator!=(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for inequality.
Definition: VariantPixelBuffer.cpp:423
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:101
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:175
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:264
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:125
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
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:383
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:225
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:721
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:774
Properties of UINT16 pixels.
Definition: PixelProperties.h:208
Map a given PixelPropertiesType enum to the corresponding language types.
Definition: PixelProperties.h:61
Properties of COMPLEX pixels.
Definition: PixelProperties.h:335
Properties of UINT32 pixels.
Definition: PixelProperties.h:231
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
Definition: VariantPixelBuffer.h:919
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:234
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:828
const size_type * shape() const
Get the shape of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:354
PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
Raw pixel type used in public interfaces.
Definition: VariantPixelBuffer.h:135
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:798
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:158
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:830
Properties of INT32 pixels.
Definition: PixelProperties.h:162
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:122
Convert T into a buffer.
Definition: VariantPixelBuffer.h:115
ome::compat::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:118
Properties of DOUBLECOMPLEX pixels.
Definition: PixelProperties.h:358
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:883
const T * origin() const
Get the origin of the array.
Definition: VariantPixelBuffer.h:952
VariantPixelBuffer & operator=(const VariantPixelBuffer &rhs)
Assign a pixel buffer.
Definition: VariantPixelBuffer.cpp:410
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:825
Properties of UINT8 pixels.
Definition: PixelProperties.h:185
boost::general_storage_order< dimensions > storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: PixelBuffer.h:121
Native endian.
Definition: Types.h:72
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:891
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:851
boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT >, PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE >, PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX >, PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX > > float_pixel_types
Floating-point pixel types.
Definition: VariantPixelBuffer.h:107
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:128
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:764
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:878
bool valid() const
Check the buffer validity.
Definition: VariantPixelBuffer.cpp:326
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:68
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:193
const variant_buffer_type & vbuffer() const
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:245
Properties of DOUBLE pixels.
Definition: PixelProperties.h:277
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:838
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:685
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:731
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:984
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:904
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:718
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:284
variant_buffer_type buffer
Pixel storage.
Definition: VariantPixelBuffer.h:644
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:795
ome::compat::array< boost::multi_array_types::index, PixelBufferBase::dimensions > indices_type
Type used to index all dimensions in public interfaces.
Definition: VariantPixelBuffer.h:141
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:767
boost::detail::multi_array::extent_gen< dimensions > range_type
Extent range type.
Definition: PixelBuffer.h:124
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:652
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:147
static const uint16_t dimensions
Total number of supported dimensions.
Definition: PixelBuffer.h:108
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
Properties of BIT pixels.
Definition: PixelProperties.h:300
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:317
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
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
VariantPixelBuffer(ome::compat::shared_ptr< PixelBuffer< T > > &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:218
boost::multi_array_types::size_type size_type
Size type.
Definition: VariantPixelBuffer.h:138
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:967
boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
Buffer type, allowing assignment of all buffer types.
Definition: VariantPixelBuffer.h:132
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
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 INT16 pixels.
Definition: PixelProperties.h:139
Logical sub-channel (typically used for RGB channel sub-components) (S).
Definition: PixelBuffer.h:86