bioformats  5.1.8
Classes | Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | List of all members
ome::bioformats::VariantPixelBuffer Class Reference

Buffer for all pixel types. More...

#include <ome/bioformats/VariantPixelBuffer.h>

Classes

struct  make_buffer
 Convert T into a buffer. More...
 

Public Types

typedef boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
 Buffer type, allowing assignment of all buffer types.
 
typedef PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
 Raw pixel type used in public interfaces.
 
typedef boost::multi_array_types::size_type size_type
 Size type.
 
typedef ome::compat::array< boost::multi_array_types::index, PixelBufferBase::dimensionsindices_type
 Type used to index all dimensions in public interfaces.
 
typedef PixelBufferBase::storage_order_type storage_order_type
 Storage ordering type for controlling pixel memory layout.
 
typedef PixelBufferBase::range_type range_type
 Extent range type.
 

Public Member Functions

 VariantPixelBuffer ()
 Default constructor. More...
 
template<class ExtentList >
 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). More...
 
 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). More...
 
 VariantPixelBuffer (const VariantPixelBuffer &buffer)
 Copy constructor. More...
 
template<typename T >
 VariantPixelBuffer (ome::compat::shared_ptr< PixelBuffer< T > > &buffer)
 Construct from existing pixel buffer. More...
 
virtual ~VariantPixelBuffer ()
 Destructor.
 
variant_buffer_typevbuffer ()
 Get a reference to the variant buffer. More...
 
const variant_buffer_typevbuffer () const
 Get a reference to the variant buffer. More...
 
template<class ExtentList >
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). More...
 
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). More...
 
bool managed () const
 Check if the buffer is internally managed. More...
 
size_type num_elements () const
 Get the number of pixel elements in the multi-dimensional array.
 
size_type num_dimensions () const
 Get the number of dimensions in the multi-dimensional array.
 
const size_typeshape () const
 Get the shape of the multi-dimensional array. More...
 
const boost::multi_array_types::index * strides () const
 Get the strides of the multi-dimensional array. More...
 
const boost::multi_array_types::index * index_bases () const
 Get the index bases of the multi-dimensional array. More...
 
template<typename T >
const T * origin () const
 Get the origin of the array. More...
 
const storage_order_typestorage_order () const
 Get the array storage order. More...
 
::ome::xml::model::enums::PixelType pixelType () const
 Get the type of pixels stored in the buffer.
 
EndianType endianType () const
 Get the endianness of the pixel type stored in the buffer.
 
template<typename T >
PixelBuffer< T >::array_ref_type & array ()
 Get the pixel data. More...
 
template<typename T >
const PixelBuffer< T >::array_ref_type & array () const
 Get the pixel data. More...
 
raw_typedata ()
 Get raw buffered data. More...
 
const raw_typedata () const
 Get raw buffered data. More...
 
template<typename T >
T * data ()
 Get raw buffered data. More...
 
template<typename T >
const T * data () const
 Get raw buffered data. More...
 
bool valid () const
 Check the buffer validity. More...
 
VariantPixelBufferoperator= (const VariantPixelBuffer &rhs)
 Assign a pixel buffer. More...
 
bool operator== (const VariantPixelBuffer &rhs) const
 Compare a pixel buffer for equality. More...
 
bool operator!= (const VariantPixelBuffer &rhs) const
 Compare a pixel buffer for inequality. More...
 
template<typename InputIterator >
void assign (InputIterator begin, InputIterator end)
 Assign pixel values. More...
 
template<class charT , class traits >
void read (std::basic_istream< charT, traits > &stream)
 Read raw pixel data from a stream in physical storage order. More...
 
template<class charT , class traits >
void write (std::basic_ostream< charT, traits > &stream) const
 Write raw pixel data to a stream in physical storage order. More...
 
template<typename T >
PixelBuffer< T >::array_ref_type & array ()
 Get the pixel data. More...
 
template<typename T >
const PixelBuffer< T >::array_ref_type & array () const
 Get the pixel data. More...
 

Static Protected Member Functions

template<class T , class ExtentList >
static variant_buffer_type makeBuffer (const ExtentList &extents, const storage_order_type &storage,::ome::xml::model::enums::PixelType pixeltype)
 Create buffer from extents (helper). More...
 
template<class T >
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). More...
 
template<class ExtentList >
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). More...
 
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). More...
 

Protected Attributes

variant_buffer_type buffer
 Pixel storage.
 

Private Types

typedef 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.
 
typedef 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.
 
typedef boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type basic_pixel_types_view
 Aggregate view of all numeric types.
 
typedef boost::mpl::transform_view< basic_pixel_types_view, make_buffer< boost::mpl::_1 > >::type pixel_buffer_types_view
 Aggregate view of all buffer types.
 
typedef boost::mpl::vector empty_types
 Empty vector placeholder.
 
typedef 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.
 

Detailed Description

Buffer for all pixel types.

The purpose of this class is to allow transfer of pixel data of any type and of any dimensionality.

This class uses Boost.Variant to support specializations of PixelBuffer for all combinations of pixel type (excluding endian variants).

For high performance access to the pixel data, use of a boost::static_visitor is recommended. This has the benefit of generalising the algorithm to operate on all PixelBuffer types, as well as allowing special casing for particular types (e.g. integer vs. float, signed vs. unsigned, simple vs. complex, or any other distinction which affects the algorithm). This will also allow subsetting of the data if required, again for all pixel types with special casing being possible.

Todo:
Add support for subsetting dimensions.

Constructor & Destructor Documentation

ome::bioformats::VariantPixelBuffer::VariantPixelBuffer ( )
inlineexplicit

Default constructor.

This constructs a pixel buffer of unspecified type, of size 1 in all dimensions. The desired type and size should be set after construction.

template<class ExtentList >
ome::bioformats::VariantPixelBuffer::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() 
)
inlineexplicit

Construct from extents (internal storage).

Storage for the buffer will be allocated internally.

Parameters
extentsthe extent of each dimension.
storagethe storage ordering, defaulting to C array storage ordering.
pixeltypethe pixel type to store.
ome::bioformats::VariantPixelBuffer::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() 
)
inlineexplicit

Construct from ranges (internal storage).

Storage for the buffer will be allocated internally.

Parameters
rangethe range of each dimension.
storagethe storage ordering, defaulting to C array storage ordering.
pixeltypethe pixel type to store.
ome::bioformats::VariantPixelBuffer::VariantPixelBuffer ( const VariantPixelBuffer buffer)
explicit

Copy constructor.

Note that due to the use of shared pointers this only performs a shallow copy.

Parameters
bufferthe buffer to copy.

References buffer.

template<typename T >
ome::bioformats::VariantPixelBuffer::VariantPixelBuffer ( ome::compat::shared_ptr< PixelBuffer< T > > &  buffer)
inlineexplicit

Construct from existing pixel buffer.

Use for referencing external data.

Parameters
bufferthe buffer to contain.

Member Function Documentation

template<typename T >
PixelBuffer<T>::array_ref_type& ome::bioformats::VariantPixelBuffer::array ( )

Get the pixel data.

Returns
the multidimensional pixel data array; this value will never be null.
Exceptions
ifthe contained PixelBuffer is not of the specified type.
template<typename T >
const PixelBuffer<T>::array_ref_type& ome::bioformats::VariantPixelBuffer::array ( ) const

Get the pixel data.

Returns
the multidimensional pixel data array; this value will never be null.
Exceptions
ifthe contained PixelBuffer is not of the specified type.
template<typename T >
PixelBuffer<T>::array_ref_type& ome::bioformats::VariantPixelBuffer::array ( )
inline

Get the pixel data.

Returns
the multidimensional pixel data array; this value will never be null.
Exceptions
ifthe contained PixelBuffer is not of the specified type.

References buffer.

template<typename T >
const PixelBuffer<T>::array_ref_type& ome::bioformats::VariantPixelBuffer::array ( ) const
inline

Get the pixel data.

Returns
the multidimensional pixel data array; this value will never be null.
Exceptions
ifthe contained PixelBuffer is not of the specified type.

References buffer.

template<typename InputIterator >
void ome::bioformats::VariantPixelBuffer::assign ( InputIterator  begin,
InputIterator  end 
)
inline

Assign pixel values.

Assign all pixel values from an input iterator.

Note that the range to assign must be equal to num_elements().

Parameters
beginthe start of the range to assign.
endthe end of the range to assign.
beginthe start of input.
endthe end of input.
Exceptions
ifthe PixelBuffer is null or the PixelBuffer's data array is null.

References buffer.

template<class ExtentList >
static variant_buffer_type ome::bioformats::VariantPixelBuffer::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() 
)
inlinestaticprotected

Create buffer from extents (internal storage).

Storage for the buffer will be allocated internally.

Parameters
extentsthe extent of each dimension.
pixeltypethe pixel type to store.
storagethe storage ordering, defaulting to C array storage ordering.
Returns
the new buffer contained in a variant.

Referenced by setBuffer().

+ Here is the caller graph for this function:

static variant_buffer_type ome::bioformats::VariantPixelBuffer::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() 
)
inlinestaticprotected

Create buffer from ranges (helper).

Storage for the buffer will be allocated internally.

Parameters
rangethe range of each dimension.
pixeltypethe pixel type to store.
storagethe storage ordering, defaulting to C array storage ordering.
Returns
the new buffer contained in a variant.
VariantPixelBuffer::raw_type * ome::bioformats::VariantPixelBuffer::data ( )

Get raw buffered data.

Returns
a pointer to the buffer start address.

References buffer.

const VariantPixelBuffer::raw_type * ome::bioformats::VariantPixelBuffer::data ( ) const

Get raw buffered data.

Returns
a pointer to the buffer start address.

References buffer.

template<typename T >
T * ome::bioformats::VariantPixelBuffer::data ( )
inline

Get raw buffered data.

Returns
a pointer to the buffer start address.
Exceptions
ifthe contained PixelBuffer is not of the specified type.

References buffer.

template<typename T >
const T * ome::bioformats::VariantPixelBuffer::data ( ) const
inline

Get raw buffered data.

Returns
a pointer to the buffer start address.
Exceptions
ifthe contained PixelBuffer is not of the specified type.

References buffer.

const boost::multi_array_types::index * ome::bioformats::VariantPixelBuffer::index_bases ( ) const

Get the index bases of the multi-dimensional array.

The index bases are the numeric index of the first element for each array dimension of the multi-dimensional array.

Returns
an array of index bases (size is the dimension size).

References buffer.

template<class T , class ExtentList >
static variant_buffer_type ome::bioformats::VariantPixelBuffer::makeBuffer ( const ExtentList &  extents,
const storage_order_type storage,
::ome::xml::model::enums::PixelType  pixeltype 
)
inlinestaticprotected

Create buffer from extents (helper).

Storage for the buffer will be allocated internally.

Parameters
extentsthe extent of each dimension.
storagethe storage ordering, defaulting to C array storage ordering.
pixeltypethe pixel type to store.
Returns
the new buffer contained in a variant.

References ome::bioformats::ENDIAN_NATIVE.

template<class T >
static variant_buffer_type ome::bioformats::VariantPixelBuffer::makeBuffer ( const range_type range,
const storage_order_type storage,
::ome::xml::model::enums::PixelType  pixeltype 
)
inlinestaticprotected

Create buffer from ranges (helper).

Storage for the buffer will be allocated internally.

Parameters
rangethe range of each dimension.
storagethe storage ordering, defaulting to C array storage ordering.
pixeltypethe pixel type to store.
Returns
the new buffer contained in a variant.

References ome::bioformats::ENDIAN_NATIVE.

bool ome::bioformats::VariantPixelBuffer::managed ( ) const

Check if the buffer is internally managed.

Returns
true if the MultiArray data is managed internally (i.e. is a multi_array) or false if not managed (i.e. is a multi_array_ref).

References buffer.

bool ome::bioformats::VariantPixelBuffer::operator!= ( const VariantPixelBuffer rhs) const

Compare a pixel buffer for inequality.

Parameters
rhsthe pixel buffer to compare with.
Returns
true if not equal, false if equal.
VariantPixelBuffer & ome::bioformats::VariantPixelBuffer::operator= ( const VariantPixelBuffer rhs)

Assign a pixel buffer.

The dimension extents must be compatible, but the storage ordering does not. The buffer contents will be assigned in the logical order rather than the storage order.

Parameters
rhsthe pixel buffer to assign.
Returns
the assigned buffer.

References buffer.

bool ome::bioformats::VariantPixelBuffer::operator== ( const VariantPixelBuffer rhs) const

Compare a pixel buffer for equality.

Parameters
rhsthe pixel buffer to compare with.
Returns
true if equal, false if not equal.

References buffer.

template<typename T >
const T * ome::bioformats::VariantPixelBuffer::origin ( ) const
inline

Get the origin of the array.

This is the address of the element at [0][0][0][0][0][0][0][0][0]. Note that this is not always the buffer start address, depending upon the dimension ordering.

Returns
the address of the array origin.

References buffer.

template<class charT , class traits >
void ome::bioformats::VariantPixelBuffer::read ( std::basic_istream< charT, traits > &  stream)
inline

Read raw pixel data from a stream in physical storage order.

Note that the pixels will be read in the physical storage order. This will typically be a contiguous read, but this is not guaranteed. The current implementation iterates over each pixel and so may be slower than strictly necessary.

Parameters
streamthe stream to read from.

References buffer.

template<class ExtentList >
void ome::bioformats::VariantPixelBuffer::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() 
)
inline

Set the buffer from extents (helper).

Storage for the buffer will be allocated internally.

Parameters
extentsthe extent of each dimension.
pixeltypethe pixel type to store.
storagethe storage ordering, defaulting to C array storage ordering.

References buffer, and createBuffer().

Referenced by ome::bioformats::detail::CopySubchannelVisitor::operator()(), ome::bioformats::tiff::IFD::readImage(), ome::bioformats::tiff::IFD::readLookupTable(), and ome::bioformats::detail::FormatReader::readPlane().

+ Here is the caller graph for this function:

void ome::bioformats::VariantPixelBuffer::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() 
)
inline

Set the buffer from ranges (internal storage).

Storage for the buffer will be allocated internally.

Parameters
rangethe range of each dimension.
pixeltypethe pixel type to store.
storagethe storage ordering, defaulting to C array storage ordering.

References buffer, and createBuffer().

const boost::multi_array_types::size_type * ome::bioformats::VariantPixelBuffer::shape ( ) const

Get the shape of the multi-dimensional array.

The shape is the extent of each array dimension.

Returns
an array of extents (size is the dimension size).

References buffer.

Referenced by ome::bioformats::tiff::IFD::readImage(), ome::bioformats::detail::FormatReader::readPlane(), and ome::bioformats::tiff::IFD::writeImage().

+ Here is the caller graph for this function:

const VariantPixelBuffer::storage_order_type & ome::bioformats::VariantPixelBuffer::storage_order ( ) const

Get the array storage order.

Returns
the storage order.

References buffer.

Referenced by ome::bioformats::tiff::IFD::readImage(), ome::bioformats::detail::FormatReader::readPlane(), and ome::bioformats::tiff::IFD::writeImage().

+ Here is the caller graph for this function:

const boost::multi_array_types::index * ome::bioformats::VariantPixelBuffer::strides ( ) const

Get the strides of the multi-dimensional array.

The strides are the stride associated with each array dimension.

Returns
an array of strides (size is the dimension size).

References buffer.

bool ome::bioformats::VariantPixelBuffer::valid ( ) const

Check the buffer validity.

This tests if the MultiArray is not null, and hence safe to use. Note that this is not a guarantee of safety in the case of using an externally managed data buffer, in which case the external buffer must still be valid in addition.

Returns
true if not null, false if null.

References buffer.

variant_buffer_type& ome::bioformats::VariantPixelBuffer::vbuffer ( )
inline

Get a reference to the variant buffer.

Returns
a reference to the buffer.

References buffer.

Referenced by ome::bioformats::detail::CopySubchannelVisitor::operator()(), ome::bioformats::detail::MergeSubchannelVisitor::operator()(), ome::bioformats::tiff::IFD::readImage(), ome::bioformats::tiff::IFD::readLookupTable(), ome::bioformats::detail::FormatReader::readPlane(), ome::qtwidgets::gl::Image2D::setPlane(), and ome::bioformats::tiff::IFD::writeImage().

+ Here is the caller graph for this function:

const variant_buffer_type& ome::bioformats::VariantPixelBuffer::vbuffer ( ) const
inline

Get a reference to the variant buffer.

Returns
a reference to the buffer.

References buffer.

template<class charT , class traits >
void ome::bioformats::VariantPixelBuffer::write ( std::basic_ostream< charT, traits > &  stream) const
inline

Write raw pixel data to a stream in physical storage order.

Note that the pixels will be written in the physical storage order. This will typically be a contiguous read, but this is not guaranteed. The current implementation iterates over each pixel and so may be slower than strictly necessary.

Parameters
streamthe stream to write to.

References buffer.


The documentation for this class was generated from the following files: