bioformats
5.1.6
|
Buffer for a specific pixel type. More...
#include <ome/bioformats/PixelBuffer.h>
Public Types | |
typedef T | value_type |
Pixel value type. | |
typedef boost::multi_array_ref< value_type, dimensions > | array_ref_type |
Type for multi-dimensional pixel array view referencing external data. More... | |
typedef boost::multi_array< value_type, dimensions > | array_type |
Type for multi-dimensional pixel array view. More... | |
Public Types inherited from ome::bioformats::PixelBufferBase | |
typedef boost::multi_array_types::size_type | size_type |
Size type. | |
typedef boost::multi_array_types::index | index |
Index type. | |
typedef ome::compat::array< boost::multi_array_types::index, PixelBufferBase::dimensions > | indices_type |
Type used to index all dimensions in public interfaces. | |
typedef boost::general_storage_order< dimensions > | storage_order_type |
Storage ordering type for controlling pixel memory layout. | |
typedef boost::detail::multi_array::extent_gen< dimensions > | range_type |
Extent range type. | |
Public Member Functions | |
PixelBuffer () | |
Default constructor. More... | |
template<class ExtentList > | |
PixelBuffer (const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, EndianType endiantype=ENDIAN_NATIVE, const storage_order_type &storage=PixelBufferBase::default_storage_order()) | |
Construct from extents (internal storage). More... | |
template<class ExtentList > | |
PixelBuffer (value_type *pixeldata, const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, EndianType endiantype=ENDIAN_NATIVE, const storage_order_type &storage=PixelBufferBase::default_storage_order()) | |
Construct from extents (external storage). More... | |
PixelBuffer (const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, EndianType endiantype=ENDIAN_NATIVE, const storage_order_type &storage=PixelBufferBase::default_storage_order()) | |
Construct from ranges (internal storage). More... | |
PixelBuffer (value_type *pixeldata, const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, EndianType endiantype=ENDIAN_NATIVE, const storage_order_type &storage=PixelBufferBase::default_storage_order()) | |
Construct from ranges (external storage). More... | |
PixelBuffer (const PixelBuffer &buffer) | |
Copy constructor. More... | |
virtual | ~PixelBuffer () |
Destructor. | |
array_ref_type & | array () |
Get the pixel data. More... | |
const array_ref_type & | array () const |
Get the pixel data. More... | |
value_type * | data () |
Get the raw data. More... | |
const value_type * | data () const |
Get the raw data. More... | |
bool | valid () const |
Check the buffer validity. 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_type * | shape () 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... | |
const value_type * | origin () const |
Get the origin of the array. More... | |
const storage_order_type & | storage_order () const |
Get the array storage order. More... | |
PixelBuffer & | operator= (const PixelBuffer &rhs) |
Assign a pixel buffer. More... | |
PixelBuffer & | operator= (const array_ref_type &rhs) |
Assign a pixel buffer. More... | |
bool | operator== (const PixelBuffer &rhs) const |
Compare a pixel buffer for equality. More... | |
bool | operator== (const array_ref_type &rhs) const |
Compare a pixel buffer for equality with a multiarray. More... | |
bool | operator!= (const PixelBuffer &rhs) const |
Compare a pixel buffer for inequality. More... | |
bool | operator!= (const array_ref_type &rhs) const |
Compare a pixel buffer for inequality with a multiarray. More... | |
bool | operator< (const PixelBuffer &rhs) const |
Less than comparison with a pixel buffer. More... | |
bool | operator< (const array_ref_type &rhs) const |
Less than comparison with a multiarray. More... | |
bool | operator<= (const PixelBuffer &rhs) const |
Less than or equal comparison with a pixel buffer. More... | |
bool | operator<= (const array_ref_type &rhs) const |
Less than or equal comparison with a multiarray. More... | |
bool | operator> (const PixelBuffer &rhs) const |
Greater than comparison with a pixel buffer. More... | |
bool | operator> (const array_ref_type &rhs) const |
Greater than comparison with a multiarray. More... | |
bool | operator>= (const PixelBuffer &rhs) const |
Greater than or equal comparison with a pixel buffer. More... | |
bool | operator>= (const array_ref_type &rhs) const |
Greater than or equal comparison with a multiarray. More... | |
template<typename InputIterator > | |
void | assign (InputIterator begin, InputIterator end) |
Assign pixel values. More... | |
value_type & | at (const indices_type &indices) |
Get the pixel value at an index. More... | |
const value_type & | at (const indices_type &indices) const |
Get the pixel value at an index. 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... | |
Public Member Functions inherited from ome::bioformats::PixelBufferBase | |
virtual | ~PixelBufferBase () |
Destructor. | |
::ome::xml::model::enums::PixelType | pixelType () const |
Get the pixel type in use. More... | |
EndianType | endianType () const |
Get the endian type in use. More... | |
Private Attributes | |
boost::variant< ome::compat::shared_ptr< array_type >, ome::compat::shared_ptr< array_ref_type > > | multiarray |
Multi-dimensional pixel array. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from ome::bioformats::PixelBufferBase | |
static storage_order_type | make_storage_order (ome::xml::model::enums::DimensionOrder order, bool interleaved) |
Generate storage ordering for a given dimension order. More... | |
static storage_order_type | default_storage_order () |
Generate default storage ordering. More... | |
Static Public Attributes inherited from ome::bioformats::PixelBufferBase | |
static const uint16_t | dimensions = 9 |
Total number of supported dimensions. | |
Protected Member Functions inherited from ome::bioformats::PixelBufferBase | |
PixelBufferBase (::ome::xml::model::enums::PixelType pixeltype, EndianType endiantype) | |
Constructor. More... | |
Buffer for a specific pixel type.
The purpose of this class is to allow transfer of pixel data of specific type and endianness, and of any dimensionality.
Internally, multi-dimensional order is achieved using Boost.MultiArray
. The MultiArray
data buffer is provided internally by default, but may also be provided externally, for example from a memory-mapped file.
Nine dimensions are currently supported.
The logical dimension ordering is the order used by the interface. However, the storage ordering in memory may be completely different. These may differ when:
If the order the data is accessed in differs from the underlying storage order, there may be a significant performance cost. It is recommended that users should query the storage ordering to iterate over the pixels in the optimal order or require a specific ordering. Reordering the data may also bear a significant cost.
typedef boost::multi_array_ref<value_type, dimensions> ome::bioformats::PixelBuffer< T >::array_ref_type |
Type for multi-dimensional pixel array view referencing external data.
This type is always a view over a separate buffer.
typedef boost::multi_array<value_type, dimensions> ome::bioformats::PixelBuffer< T >::array_type |
Type for multi-dimensional pixel array view.
This type uses an internal data buffer.
|
inlineexplicit |
Default constructor.
This constructs a pixel buffer of size 1 in all dimensions. The desired size should be set after construction.
|
inlineexplicit |
Construct from extents (internal storage).
Storage for the buffer will be allocated internally.
extents | the extent of each dimension. |
pixeltype | the pixel type to store. |
endiantype | the required endianness of the pixel type. |
storage | the storage ordering, defaulting to C array storage ordering. |
|
inlineexplicit |
Construct from extents (external storage).
Storage for the buffer must be pre-allocated by the caller and must exist for the lifetime of this object.
pixeldata | the externally-provided storage for pixel data. |
extents | the extent of each dimension. |
pixeltype | the pixel type to store. |
endiantype | the required endianness of the pixel type. |
storage | the storage ordering, defaulting to C array storage ordering. |
|
inlineexplicit |
Construct from ranges (internal storage).
Storage for the buffer will be allocated internally.
range | the range of each dimension. |
pixeltype | the pixel type to store. |
endiantype | the required endianness of the pixel type. |
storage | the storage ordering, defaulting to C array storage ordering. |
|
inlineexplicit |
Construct from ranges (external storage).
Storage for the buffer must be pre-allocated by the caller and must exist for the lifetime of this object.
pixeldata | the externally-provided storage for pixel data. |
range | the range of each dimension. |
pixeltype | the pixel type to store. |
endiantype | the required endianness of the pixel type. |
storage | the storage ordering, defaulting to C array storage ordering. |
|
inlineexplicit |
Copy constructor.
Note that due to the use of shared pointers this only performs a shallow copy.
buffer | the buffer to copy. |
PixelBuffer< T >::array_ref_type & ome::bioformats::PixelBuffer< T >::array | ( | ) |
Get the pixel data.
Referenced by ome::bioformats::PixelBuffer< T >::assign(), ome::bioformats::PixelBuffer< T >::at(), ome::bioformats::PixelBuffer< T >::data(), ome::bioformats::PixelBuffer< T >::index_bases(), ome::bioformats::PixelBuffer< T >::num_dimensions(), ome::bioformats::PixelBuffer< T >::num_elements(), ome::bioformats::PixelBuffer< T >::operator!=(), ome::bioformats::PixelBuffer< T >::operator<(), ome::bioformats::PixelBuffer< T >::operator<=(), ome::bioformats::PixelBuffer< T >::operator=(), ome::bioformats::PixelBuffer< T >::operator==(), ome::bioformats::PixelBuffer< T >::operator>(), ome::bioformats::PixelBuffer< T >::operator>=(), ome::bioformats::PixelBuffer< T >::origin(), ome::bioformats::PixelBuffer< T >::shape(), ome::bioformats::PixelBuffer< T >::storage_order(), ome::bioformats::PixelBuffer< T >::strides(), and ome::bioformats::PixelBuffer< T >::valid().
const PixelBuffer< T >::array_ref_type & ome::bioformats::PixelBuffer< T >::array | ( | ) | const |
Get the pixel data.
|
inline |
Assign pixel values.
Note that the range to assign must be equal to num_elements().
begin | the start of the range to assign. |
end | the end of the range to assign. |
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Get the pixel value at an index.
indices | the multi-dimensional array index. |
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Get the pixel value at an index.
indices | the multi-dimensional array index. |
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Get the raw data.
This is the buffer referenced by the multidimensional pixel data array.
References ome::bioformats::PixelBuffer< T >::array().
Referenced by ome::bioformats::PixelBuffer< T >::read(), and ome::bioformats::PixelBuffer< T >::write().
|
inline |
Get the raw data.
This is the buffer referenced by the multidimensional pixel data array.
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
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.
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Check if the buffer is internally managed.
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 ome::bioformats::PixelBuffer< T >::multiarray.
|
inline |
Compare a pixel buffer for inequality.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Compare a pixel buffer for inequality with a multiarray.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Less than comparison with a pixel buffer.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Less than comparison with a multiarray.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Less than or equal comparison with a pixel buffer.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Less than or equal comparison with a multiarray.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
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.
rhs | the pixel buffer to assign. |
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
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.
rhs | the pixel buffer to assign. |
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Compare a pixel buffer for equality.
rhs | the pixel buffer to compare with. |
true
if equal, false
if not equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Compare a pixel buffer for equality with a multiarray.
rhs | the pixel buffer to compare with. |
true
if equal, false
if not equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Greater than comparison with a pixel buffer.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Greater than comparison with a multiarray.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Greater than or equal comparison with a pixel buffer.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Greater than or equal comparison with a multiarray.
rhs | the pixel buffer to compare with. |
true
if not equal, false
if equal. References ome::bioformats::PixelBuffer< T >::array().
|
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.
References ome::bioformats::PixelBuffer< T >::array().
|
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.
stream | the stream to read from. |
References ome::bioformats::PixelBuffer< T >::data(), and ome::bioformats::PixelBuffer< T >::num_elements().
|
inline |
Get the shape of the multi-dimensional array.
The shape is the extent of each array dimension.
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Get the array storage order.
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
Get the strides of the multi-dimensional array.
The strides are the stride associated with each array dimension.
References ome::bioformats::PixelBuffer< T >::array().
|
inline |
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.
true
if not null, false
if null. References ome::bioformats::PixelBuffer< T >::array().
|
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.
stream | the stream to write to. |
References ome::bioformats::PixelBuffer< T >::data(), and ome::bioformats::PixelBuffer< T >::num_elements().
|
private |
Multi-dimensional pixel array.
This may be either a multi_array
containing the data directly, or a multi_array_ref
using an external buffer. If using an external buffer, the lifetime of the buffer must exceed that of this class instance.
Note that a boost::variant
is used here because it's not possible to safely reference the common base or cast between them. A shared_ptr
is used here so that it is possible to resize the array by replacing the existing array and avoid the overhead of large array copies during assignment. It also permits efficient shallow copying in the absence of a C++11 move constructor for MultiArray
types.
Referenced by ome::bioformats::PixelBuffer< T >::managed().