bioformats
5.1.0
|
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::dimensions > | indices_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_type & | vbuffer () |
Get a reference to the variant buffer. More... | |
const variant_buffer_type & | vbuffer () 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_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... | |
template<typename T > | |
const T * | origin () const |
Get the origin of the array. More... | |
const storage_order_type & | storage_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_type * | data () |
Get raw buffered data. More... | |
const raw_type * | data () 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... | |
VariantPixelBuffer & | operator= (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. | |
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.
|
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.
|
inlineexplicit |
Construct from extents (internal storage).
Storage for the buffer will be allocated internally.
extents | the extent of each dimension. |
storage | the storage ordering, defaulting to C array storage ordering. |
pixeltype | the pixel type to store. |
|
inlineexplicit |
Construct from ranges (internal storage).
Storage for the buffer will be allocated internally.
range | the range of each dimension. |
storage | the storage ordering, defaulting to C array storage ordering. |
pixeltype | the pixel type to store. |
|
explicit |
Copy constructor.
Note that due to the use of shared pointers this only performs a shallow copy.
buffer | the buffer to copy. |
References buffer.
|
inlineexplicit |
Construct from existing pixel buffer.
Use for referencing external data.
buffer | the buffer to contain. |
PixelBuffer<T>::array_ref_type& ome::bioformats::VariantPixelBuffer::array | ( | ) |
Get the pixel data.
if | the contained PixelBuffer is not of the specified type. |
const PixelBuffer<T>::array_ref_type& ome::bioformats::VariantPixelBuffer::array | ( | ) | const |
Get the pixel data.
if | the contained PixelBuffer is not of the specified type. |
|
inline |
Get the pixel data.
if | the contained PixelBuffer is not of the specified type. |
References buffer.
|
inline |
Get the pixel data.
if | the contained PixelBuffer is not of the specified type. |
References buffer.
|
inline |
Assign pixel values.
Assign all pixel values from an input iterator.
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. |
begin | the start of input. |
end | the end of input. |
if | the PixelBuffer is null or the PixelBuffer's data array is null. |
References buffer.
|
inlinestaticprotected |
Create buffer from extents (internal storage).
Storage for the buffer will be allocated internally.
extents | the extent of each dimension. |
pixeltype | the pixel type to store. |
storage | the storage ordering, defaulting to C array storage ordering. |
Referenced by setBuffer().
|
inlinestaticprotected |
Create buffer from ranges (helper).
Storage for the buffer will be allocated internally.
range | the range of each dimension. |
pixeltype | the pixel type to store. |
storage | the storage ordering, defaulting to C array storage ordering. |
VariantPixelBuffer::raw_type * ome::bioformats::VariantPixelBuffer::data | ( | ) |
const VariantPixelBuffer::raw_type * ome::bioformats::VariantPixelBuffer::data | ( | ) | const |
|
inline |
Get raw buffered data.
if | the contained PixelBuffer is not of the specified type. |
References buffer.
|
inline |
Get raw buffered data.
if | the 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.
References buffer.
|
inlinestaticprotected |
Create buffer from extents (helper).
Storage for the buffer will be allocated internally.
extents | the extent of each dimension. |
storage | the storage ordering, defaulting to C array storage ordering. |
pixeltype | the pixel type to store. |
References ome::bioformats::ENDIAN_NATIVE.
|
inlinestaticprotected |
Create buffer from ranges (helper).
Storage for the buffer will be allocated internally.
range | the range of each dimension. |
storage | the storage ordering, defaulting to C array storage ordering. |
pixeltype | the pixel type to store. |
References ome::bioformats::ENDIAN_NATIVE.
bool ome::bioformats::VariantPixelBuffer::managed | ( | ) | const |
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 buffer.
bool ome::bioformats::VariantPixelBuffer::operator!= | ( | const VariantPixelBuffer & | rhs | ) | const |
Compare a pixel buffer for inequality.
rhs | the pixel buffer to compare with. |
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.
rhs | the pixel buffer to assign. |
References buffer.
bool ome::bioformats::VariantPixelBuffer::operator== | ( | const VariantPixelBuffer & | rhs | ) | const |
Compare a pixel buffer for equality.
rhs | the pixel buffer to compare with. |
true
if equal, false
if not equal. References buffer.
|
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 buffer.
|
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 buffer.
|
inline |
Set the buffer from extents (helper).
Storage for the buffer will be allocated internally.
extents | the extent of each dimension. |
pixeltype | the pixel type to store. |
storage | the 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().
|
inline |
Set the buffer from ranges (internal storage).
Storage for the buffer will be allocated internally.
range | the range of each dimension. |
pixeltype | the pixel type to store. |
storage | the 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.
References buffer.
Referenced by ome::bioformats::tiff::IFD::readImage(), ome::bioformats::detail::FormatReader::readPlane(), and ome::bioformats::tiff::IFD::writeImage().
const VariantPixelBuffer::storage_order_type & ome::bioformats::VariantPixelBuffer::storage_order | ( | ) | const |
Get the array storage order.
References buffer.
Referenced by ome::bioformats::tiff::IFD::readImage(), ome::bioformats::detail::FormatReader::readPlane(), and ome::bioformats::tiff::IFD::writeImage().
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.
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.
true
if not null, false
if null. References buffer.
|
inline |
Get a reference to the variant buffer.
References buffer.
Referenced by ome::bioformats::in::MinimalTIFFReader::openBytesImpl(), ome::bioformats::in::OMETIFFReader::openBytesImpl(), ome::bioformats::detail::CopySubchannelVisitor::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().
|
inline |
|
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 buffer.