ome-files
0.5.0
|
Buffer for all pixel types. More...
#include <ome/files/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 std::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 (std::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. More... | |
size_type | num_dimensions () const |
Get the number of dimensions in the multi-dimensional array. More... | |
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. More... | |
EndianType | endianType () const |
Get the endianness of the pixel type stored in the buffer. 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... | |
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... | |
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.
Referenced by VariantPixelBuffer().
|
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. |
References buffer, and VariantPixelBuffer().
|
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. |
|
inline |
Get the pixel data.
Get the pixel data.
if | the contained PixelBuffer is not of the specified type. |
Referenced by setBuffer().
|
inline |
Get the pixel data.
Get the pixel data.
if | the contained PixelBuffer is not of the specified type. |
|
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. |
Referenced by setBuffer().
|
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::files::VariantPixelBuffer::data | ( | ) |
Get raw buffered data.
References buffer.
Referenced by setBuffer().
const VariantPixelBuffer::raw_type * ome::files::VariantPixelBuffer::data | ( | ) | const |
|
inline |
Get raw buffered data.
if | the contained PixelBuffer is not of the specified type. |
|
inline |
Get raw buffered data.
if | the contained PixelBuffer is not of the specified type. |
EndianType ome::files::VariantPixelBuffer::endianType | ( | ) | const |
Get the endianness of the pixel type stored in the buffer.
References buffer.
Referenced by setBuffer().
const boost::multi_array_types::index * ome::files::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.
Referenced by setBuffer().
|
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::files::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::files::ENDIAN_NATIVE.
bool ome::files::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.
Referenced by setBuffer().
boost::multi_array_types::size_type ome::files::VariantPixelBuffer::num_dimensions | ( | ) | const |
Get the number of dimensions in the multi-dimensional array.
References buffer.
Referenced by setBuffer().
boost::multi_array_types::size_type ome::files::VariantPixelBuffer::num_elements | ( | ) | const |
Get the number of pixel elements in the multi-dimensional array.
References buffer.
Referenced by setBuffer().
bool ome::files::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. Referenced by setBuffer().
VariantPixelBuffer & ome::files::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.
Referenced by setBuffer().
bool ome::files::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.
Referenced by setBuffer().
|
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.
Referenced by setBuffer().
PixelType ome::files::VariantPixelBuffer::pixelType | ( | ) | const |
Get the type of pixels stored in the buffer.
References buffer.
Referenced by ome::files::tiff::IFD::readImage(), ome::files::detail::FormatReader::readPlane(), setBuffer(), and ome::files::tiff::IFD::writeImage().
|
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. |
Referenced by setBuffer(), and write().
|
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 createBuffer().
Referenced by ome::files::detail::CopySubchannelVisitor::operator()(), ome::files::tiff::IFD::readImage(), ome::files::tiff::IFD::readLookupTable(), and ome::files::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 array(), assign(), createBuffer(), data(), endianType(), index_bases(), managed(), num_dimensions(), num_elements(), operator!=(), operator=(), operator==(), origin(), pixelType(), read(), shape(), storage_order(), strides(), valid(), and write().
const boost::multi_array_types::size_type * ome::files::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::files::tiff::IFD::readImage(), ome::files::detail::FormatReader::readPlane(), setBuffer(), and ome::files::tiff::IFD::writeImage().
const VariantPixelBuffer::storage_order_type & ome::files::VariantPixelBuffer::storage_order | ( | ) | const |
Get the array storage order.
References buffer.
Referenced by ome::files::tiff::IFD::readImage(), ome::files::detail::FormatReader::readPlane(), setBuffer(), and ome::files::tiff::IFD::writeImage().
const boost::multi_array_types::index * ome::files::VariantPixelBuffer::strides | ( | ) | const |
Get the strides of the multi-dimensional array.
The strides are the stride associated with each array dimension.
References buffer.
Referenced by setBuffer().
bool ome::files::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.
Referenced by setBuffer().
|
inline |
Get a reference to the variant buffer.
References buffer.
Referenced by ome::files::detail::CopySubchannelVisitor::operator()(), ome::files::detail::MergeSubchannelVisitor::operator()(), ome::files::tiff::IFD::readImage(), ome::files::tiff::IFD::readLookupTable(), ome::files::detail::FormatReader::readPlane(), and ome::files::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 read(), and write().
Referenced by setBuffer(), and write().