| IOLink 1.11.0

Loading...
Searching...
No Matches
ImageView.h
1#pragma once
2
3#include <memory>
4
5#include <iolink/DataType.h>
6#include <iolink/FlagSet.h>
7#include <iolink/IOLinkAPI.h>
8#include <iolink/Indexer.h>
9#include <iolink/RegionX.h>
10#include <iolink/VectorX.h>
11#include <iolink/metadata/MetadataNode.h>
12#include <iolink/property/ImageProperties.h>
13#include <iolink/view/ParallelAccessExtension.h>
14#include <iolink/view/TilingInfoExtension.h>
15#include <iolink/view/View.h>
16
17 namespace iolink
18{
19
23 enum class ImageCapability
24{
25 // Flags
26 READ = 0x1,
27 WRITE = 0x2,
28 RESHAPE = 0x4,
29 MEMORY_ACCESS = 0x8,
30
31 // Combinations
32 READ_WRITE = 0x3,
33};
34
35 extern template class IOLINK_API_IMPORT FlagSet<ImageCapability>;
36
40 using ImageCapabilitySet = FlagSet<ImageCapability>;
41
42// Define bitwise operators for ImageCapability
43IOLINK_DEFINE_ENUM_BITWISE_OPERATORS(ImageCapability)
44
45
69class IOLINK_API ImageView : public View
70{
71
72 public:
73 virtual ~ImageView() = default;
74
78 inline size_t dimensionCount() { return this->shape().size(); }
79
83 inline bool support(ImageCapabilitySet flags) { return this->capabilities().has(flags); }
84
88 virtual ImageCapabilitySet capabilities() const = 0;
89
101 virtual const VectorXu64& shape() = 0;
102
106 virtual DataType dataType() = 0;
107
111 virtual std::shared_ptr<const ImageProperties> properties() = 0;
112
116 std::string toString() const;
117
118 // ==== //
119 // READ //
120 // ==== //
121
129 virtual std::shared_ptr<const MetadataNode> metadata() const;
130
142 virtual void read(const VectorXu64& index, void* dst);
143
154 virtual void readRegion(const RegionXu64& region, void* dst);
155
156 // Shortcuts
157
163 ImageInterpretation imageInterpretation();
164
170 ImageType axesInterpretation();
171
177 Vector3d spatialOrigin();
178
184 Vector3d spatialSpacing();
185
191 std::string spatialUnit();
192
198 const SpatialDirections& spatialDirections();
199
205 size_t bitDepth();
206
212 bool hasAlpha();
213
219 Vector2d valueRange();
220
221 // ===== //
222 // WRITE //
223 // ===== //
224
232 virtual void setProperties(std::shared_ptr<const ImageProperties> properties);
233
241 virtual void setMetadata(std::shared_ptr<MetadataNode> metadata);
242
254 virtual void write(const VectorXu64& index, const void* src);
255
266 virtual void writeRegion(const RegionXu64& region, const void* src);
267
268 // Shortcuts
269
275 void setImageInterpretation(const ImageInterpretation interpretation);
276
282 void setAxesInterpretation(const ImageType type);
283
289 void setSpatialOrigin(const Vector3d& origin);
290
296 void setSpatialSpacing(const Vector3d& spacing);
297
303 void setSpatialUnit(const std::string& unit);
304
310 void setSpatialDirections(const SpatialDirections& directions);
311
317 void setBitDepth(size_t bitDepth);
318
324 void setAlpha(bool value);
325
331 void setValueRange(const Vector2d& range);
332
333 // ======= //
334 // RESHAPE //
335 // ======= //
336
349 virtual void reshape(const VectorXu64& shape, DataType dataType);
350
351 // ============= //
352 // MEMORY_ACCESS //
353 // ============= //
354
362 virtual const Indexer& indexer();
363
371 virtual void* buffer();
372
380 virtual const void* bufferReadOnly() const;
381
389 virtual size_t bufferSize();
390
391 // ========== //
392 // Extensions //
393 // ========== //
394
398 std::shared_ptr<TilingInfoExtension> tilingInfo();
399
403 std::shared_ptr<ParallelAccessExtension> parallelAccess();
404};
405
406} // namespace iolink
iolink::DataType
Stores information about a data type.
Definition DataType.h:162
iolink::FlagSet
Template class to handle a flags system from an enum.
Definition FlagSet.h:43
iolink::ImageType
A flag system that describes the dimensions of an image.
Definition ImageType.h:43
iolink::ImageView
Interface representing an N dimensional image.
Definition ImageView.h:70
iolink::ImageView::spatialUnit
std::string spatialUnit()
Shortcut to access the spatial unit from image properties.
iolink::ImageView::dimensionCount
size_t dimensionCount()
Returns the dimension of the View.
Definition ImageView.h:78
iolink::ImageView::spatialOrigin
Vector3d spatialOrigin()
Shortcut to access spatial origin from image properties.
iolink::ImageView::tilingInfo
std::shared_ptr< TilingInfoExtension > tilingInfo()
Shortcut to retrieve TilingInfo extension.
iolink::ImageView::read
virtual void read(const VectorXu64 &index, void *dst)
Read the data at the given index into a buffer.
iolink::ImageView::spatialSpacing
Vector3d spatialSpacing()
Shortcut to access spatial spacing from image properties.
iolink::ImageView::capabilities
virtual ImageCapabilitySet capabilities() const =0
Return the capabilities of this image.
iolink::ImageView::dataType
virtual DataType dataType()=0
Return the data type of the samples of this image.
iolink::ImageView::writeRegion
virtual void writeRegion(const RegionXu64 &region, const void *src)
Write a input buffer into a given region of the image.
iolink::ImageView::bitDepth
size_t bitDepth()
Shortcut to access the sample bitdepth from image properties.
iolink::ImageView::axesInterpretation
ImageType axesInterpretation()
Shortcut to access axes interpretation from image properties.
iolink::ImageView::valueRange
Vector2d valueRange()
Shortcut to access the sample value range from image properties.
iolink::ImageView::hasAlpha
bool hasAlpha()
Shortcut to access hasAlpha status from image properties.
iolink::ImageView::bufferReadOnly
virtual const void * bufferReadOnly() const
Return an immutable pointer to the internal CPU memory buffer.
iolink::ImageView::spatialDirections
const SpatialDirections & spatialDirections()
Shortcut to access spatial directions from image properties.
iolink::ImageView::setAlpha
void setAlpha(bool value)
Shortcut to indicate the presence of an alpha channel into image properties.
iolink::ImageView::setSpatialOrigin
void setSpatialOrigin(const Vector3d &origin)
Shortcut to set spatial origin into image properties.
iolink::ImageView::properties
virtual std::shared_ptr< const ImageProperties > properties()=0
Return the view's properties.
iolink::ImageView::toString
std::string toString() const
Return a string representation.
iolink::ImageView::bufferSize
virtual size_t bufferSize()
Size in bytes of the internal CPU buffer.
iolink::ImageView::setValueRange
void setValueRange(const Vector2d &range)
Shortcut to set sample value range into image properties.
iolink::ImageView::setImageInterpretation
void setImageInterpretation(const ImageInterpretation interpretation)
Shortcut to set Image interpretation into image properties.
iolink::ImageView::setSpatialDirections
void setSpatialDirections(const SpatialDirections &directions)
Shortcut to set spatial direcitons into image properties.
iolink::ImageView::setAxesInterpretation
void setAxesInterpretation(const ImageType type)
Shortcut to set axes interpretation into image properties.
iolink::ImageView::support
bool support(ImageCapabilitySet flags)
Checks if the ImageView supports the given capabilities.
Definition ImageView.h:83
iolink::ImageView::parallelAccess
std::shared_ptr< ParallelAccessExtension > parallelAccess()
Shortcut to retrieve ParallelAccess extension.
iolink::ImageView::readRegion
virtual void readRegion(const RegionXu64 &region, void *dst)
Read a region of the image into a buffer.
iolink::ImageView::setBitDepth
void setBitDepth(size_t bitDepth)
Shortcut to set sample bitdepth into image properties.
iolink::ImageView::write
virtual void write(const VectorXu64 &index, const void *src)
Write value from a buffer at the given index.
iolink::ImageView::buffer
virtual void * buffer()
Return a mutable pointer to the internal CPU memory buffer.
iolink::ImageView::setProperties
virtual void setProperties(std::shared_ptr< const ImageProperties > properties)
Update the image's properties.
iolink::ImageView::metadata
virtual std::shared_ptr< const MetadataNode > metadata() const
Return the root node of the metadata attached to this image.
iolink::ImageView::imageInterpretation
ImageInterpretation imageInterpretation()
Shortcut to access Image interpretation from image properties.
iolink::ImageView::setSpatialUnit
void setSpatialUnit(const std::string &unit)
Shortcut to set spatial unit into image properties.
iolink::ImageView::indexer
virtual const Indexer & indexer()
Return an Indexer describing the memory layout of the buffer.
iolink::ImageView::reshape
virtual void reshape(const VectorXu64 &shape, DataType dataType)
Change the shape and sample data type of the image.
iolink::ImageView::shape
virtual const VectorXu64 & shape()=0
Return the shape of the image, each component containing the size in this dimension.
iolink::ImageView::setMetadata
virtual void setMetadata(std::shared_ptr< MetadataNode > metadata)
Attach a new metadata node to the image.
iolink::ImageView::setSpatialSpacing
void setSpatialSpacing(const Vector3d &spacing)
Shortcut to set spatial spacing into image properties.
iolink::Indexer
This class is used to index a classic array into a multi dimensional array.
Definition Indexer.h:36
iolink::RegionX
A Region using dynamic vectors.
Definition RegionX.h:14
iolink::SpatialDirections
Describes a spatial axis system, with direction vectors describing the three axes.
Definition SpatialDirections.h:16
iolink::Vector< double, 3 >
iolink::VectorX
A dynamically sized arithmetic vector.
Definition VectorX.h:18
iolink::View
Interface representing a generic view on data.
Definition View.h:16
iolink
All IOLink symbols are enclosed in this namespace.
Definition ArrayX.h:8
iolink::ImageInterpretation
ImageInterpretation
Interpretation of an Image.
Definition ImageInfoProperty.h:17
iolink::ImageCapability
ImageCapability
Define capabilities of an ImageView.
Definition ImageView.h:24
iolink::RandomAccessCapability::READ
@ READ
Data can be read.
iolink::RandomAccessCapability::MEMORY_ACCESS
@ MEMORY_ACCESS
Accessing internal CPU memory buffer.
iolink::RandomAccessCapability::WRITE
@ WRITE
Data can be written.
iolink::DataFrameCapability::RESHAPE
@ RESHAPE
Ability to add or remove columns and rows.