IOLink  IOL_v1.2.0_release
iolink::ImageViewFactory Class Reference

This factory is aimed at creating dataset views. More...

#include <iolink/view/ImageViewFactory.h>

Public Member Functions

 ImageViewFactory (const ImageViewFactory &other)=delete
 
 ImageViewFactory (ImageViewFactory &&other)=delete
 
ImageViewFactoryoperator= (const ImageViewFactory &other)=delete
 
ImageViewFactoryoperator= (ImageViewFactory &&other)=delete
 

Static Public Member Functions

static std::shared_ptr< ImageViewallocate (const VectorXu64 &shape, DataType type, std::shared_ptr< ImageProperties > properties, std::shared_ptr< MetadataNode > metadata)
 Creates a memory image with the given shape and type. More...
 
static std::shared_ptr< ImageViewallocate (const VectorXu64 &shape, DataType type)
 Creates a memory image with the given shape and type. More...
 
static std::shared_ptr< ImageViewcopyInMemory (std::shared_ptr< ImageView > image)
 Copy given image in memory. More...
 
static std::shared_ptr< ImageViewcreateOnDisk (const std::string &dirPath, const VectorXu64 &shape, DataType type, std::shared_ptr< ImageProperties > properties, std::shared_ptr< MetadataNode > metadata)
 Create an image with the data stored into a temporary file (in given folder) on disk in raw. More...
 
static std::shared_ptr< ImageViewcreateOnDisk (const std::string &dirPath, const VectorXu64 &shape, DataType type)
 Create an image with the data stored into a temporary file (in given folder) on disk in raw. More...
 
static std::shared_ptr< ImageViewcreateOnDisk (const VectorXu64 &shape, DataType type, std::shared_ptr< ImageProperties > properties, std::shared_ptr< MetadataNode > metadata)
 Create an image with the data stored into a temporary file on disk in raw. More...
 
static std::shared_ptr< ImageViewcreateOnDisk (const VectorXu64 &shape, DataType type)
 Create an image with the data stored into a temporary file on disk in raw. More...
 
static std::shared_ptr< ImageViewcopyOnDisk (std::shared_ptr< ImageView > image)
 Load an image data into a temporary raw file on disk. More...
 
static std::shared_ptr< ImageViewcopyOnDisk (std::shared_ptr< ImageView > image, const std::string &dirPath)
 Load an image data into a temporary raw file on disk. More...
 
static std::shared_ptr< ImageViewfromBuffer (const VectorXu64 &shape, DataType type, void *buffer, size_t bufferSize, std::shared_ptr< ImageProperties > properties, const std::shared_ptr< MetadataNode > metadata)
 Creates an image from existing buffer. More...
 
static std::shared_ptr< ImageViewfromBuffer (const VectorXu64 &shape, DataType type, void *buffer, size_t bufferSize)
 Creates an image from existing buffer. More...
 
static std::shared_ptr< ImageViewfromRandomAccess (std::shared_ptr< RandomAccess > accessor, MemoryLayout layout, const VectorXu64 &shape, const DataType type, std::shared_ptr< ImageProperties > properties, const std::shared_ptr< const MetadataNode > metadata)
 Create an image from a RandomAccess. More...
 
static std::shared_ptr< ImageViewfromRandomAccess (std::shared_ptr< RandomAccess > accessor, MemoryLayout layout, const VectorXu64 &shape, const DataType type)
 Create an image from a RandomAccess. More...
 
static std::shared_ptr< ImageViewfromRandomAccess (std::shared_ptr< RandomAccess > accessor, const VectorXu64 &shape, const DataType type, std::shared_ptr< ImageProperties > properties, std::shared_ptr< const MetadataNode > metadata)
 Create an image from a given RandomAccess. More...
 
static std::shared_ptr< ImageViewfromRandomAccess (std::shared_ptr< RandomAccess > accessor, const VectorXu64 &shape, const DataType type)
 Create an image from a given RandomAccess. More...
 
static std::shared_ptr< ImageViewfromImageView (std::shared_ptr< ImageView > view, std::shared_ptr< const ImageProperties > properties, std::shared_ptr< const MetadataNode > metadata)
 Allows to apply specific properties and metadata to a ImageView without impact on originals. More...
 
static std::shared_ptr< ImageViewuniform (const VectorXu64 &shape, DataType type, void *value, std::shared_ptr< ImageProperties > properties, std::shared_ptr< const MetadataNode > metadata)
 Create an image with uniform value. More...
 
static std::shared_ptr< ImageViewuniform (const VectorXu64 &shape, DataType type, void *value)
 Create an image with uniform value. More...
 
static std::shared_ptr< ImageViewadaptDynamicRange (std::shared_ptr< ImageView > view, DataType type, const Vector2d &inputRange, const Vector2d &outputRange)
 Creates an ImageView from another view with given type by mapping dynamic range. More...
 
static std::shared_ptr< ImageViewadaptDataType (std::shared_ptr< ImageView > view, DataType type)
 Creates an ImageView from another view with given type. More...
 
static std::shared_ptr< ImageViewextractChannel (std::shared_ptr< ImageView > view, size_t idxChannel)
 Returns an ImageView from another view containing only given channel Index (useful when channel is not clearly identified). More...
 
static std::shared_ptr< ImageViewextractRegion (std::shared_ptr< ImageView > view, const RegionXu64 &region)
 Creates an ImageView of given region from given view. More...
 
static std::shared_ptr< ImageViewextractAdjustedRegion (std::shared_ptr< ImageView > view, const RegionXu64 &region)
 Creates an ImageView of given region from given view, packing flat dimensions. More...
 
static std::shared_ptr< ImageViewstack (std::shared_ptr< MultiImageView > view, ImageDimension newDimension)
 Creates an ImageView from a multiImageView by agglomerating frames into a new given dimension. More...
 
static std::shared_ptr< ImageViewstack (std::shared_ptr< MultiImageView > view)
 Creates an ImageView from a multiImageView by agglomerating frames into a new unidentified dimension. More...
 
static std::shared_ptr< ImageViewassembleChannels (std::shared_ptr< ImageView > image)
 Adapt a N dimensions scalar ImageView into a N-1 dimensions vectorial one. More...
 
static std::shared_ptr< ImageViewdisassembleChannels (std::shared_ptr< ImageView > image)
 Adapt a N dimensions vectorial ImageView into a N+1 dimensions scalar one. More...
 
static std::shared_ptr< ImageViewinterlace (std::shared_ptr< MultiImageView > multiView, ImageInterpretation newInterpretation, bool hasAlpha)
 Interlace frames of a MultiImageView into an ImageView. More...
 
static std::shared_ptr< ImageViewinterlace (std::shared_ptr< MultiImageView > multiView)
 Interlace frames of a MultiImageView into an ImageView. More...
 
static std::shared_ptr< ImageViewreinterpret (std::shared_ptr< ImageView > image, ImageType newImageType)
 Reinterpret an ImageView with a new ImageTypeId. More...
 
static std::shared_ptr< ImageViewreinterpretAxes (std::shared_ptr< ImageView > image, std::initializer_list< ImageDimension > dimensionsList)
 Reinterpret an ImageView by identifying each dimension (axis). More...
 
static std::shared_ptr< ImageViewreinterpretAxes (std::shared_ptr< ImageView > image, const ImageDimension *dimensionsList, size_t count)
 Reinterpret an ImageView by identifying each dimension (axis). More...
 
static std::shared_ptr< ImageViewsubSample (std::shared_ptr< ImageView > image, size_t step)
 Create a sub-sampled imageView from original. More...
 
static std::shared_ptr< ImageViewflip (std::shared_ptr< ImageView > image, ImageDimension dimension)
 Flip an ImageView following the given dimension. More...
 
static std::shared_ptr< ImageViewflip (std::shared_ptr< ImageView > image, size_t dimensionIndex)
 Flip an ImageView following the given dimension. More...
 
static std::shared_ptr< ImageViewmakeThreadSafe (std::shared_ptr< ImageView > image)
 Make an ImageView threadsafe. More...
 

Detailed Description

This factory is aimed at creating dataset views.

By default, ImageViews returned by this factory are not thread safe. Only makeThreadSafe method allows to apply threadsafety guarantee on an ImageView.

Member Function Documentation

◆ adaptDataType()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::adaptDataType ( std::shared_ptr< ImageView view,
DataType  type 
)
static

Creates an ImageView from another view with given type.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE

One or many adapters will be added if necessary to convert from input view type to output View type. Data will be mapped to full output type range. For example, if given view is 16 bits with valueRange [1000, 2000] and type is uint8, input range [1000, 2000] will be mapped to output range [0, 255].

Input data range are read from view properties. Output range is specified type standard range. It can be retrieved with DataType::standardRange(type).

Parameters
viewThe source image
typeThe target datatype
Exceptions
InvalidArgumentIf the view is null
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentIf type cardinality is different of original type
InvalidArgumentIf given type is not numeric
Errorif Input view does not support READ or WRITE capability

◆ adaptDynamicRange()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::adaptDynamicRange ( std::shared_ptr< ImageView view,
DataType  type,
const Vector2d inputRange,
const Vector2d outputRange 
)
static

Creates an ImageView from another view with given type by mapping dynamic range.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE

This method will map [inputRange[0], inputRange[1]] -> [outputRange[0], outputRange[1]]

One or many adapters will be added if necessary to convert from input view type to output View type. Data will be mapped to full output type range. For example, if given view is 16 bits with valueRange [1000, 2000] and type is uint8 with input range [20, 50], input range [1000, 2000] will be mapped to output range [20, 50].

If input image contains value outside of given inputRange, these values will be linearly mapped outside of outputRange. For example, with [0, 1]->[0, 2], a value of -1 will be mapped to -2.

Warning
No clamp are done for values outside of type admissible values. Invalid ranges may lead to overflow issues.
Parameters
viewInput view
typeRequested data type
inputRangeRange of data in input view
outputRangeRequested output range
Exceptions
InvalidArgumentIf the view is null
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentIf type cardinality is different of original type
InvalidArgumentIf given type is not numeric
Errorif Input view does not support READ or WRITE capability

◆ allocate() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::allocate ( const VectorXu64 shape,
DataType  type 
)
static

Creates a memory image with the given shape and type.

Memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • BUFFER
  • RESHAPE
Parameters
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.

◆ allocate() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::allocate ( const VectorXu64 shape,
DataType  type,
std::shared_ptr< ImageProperties properties,
std::shared_ptr< MetadataNode metadata 
)
static

Creates a memory image with the given shape and type.

Memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • BUFFER
  • RESHAPE
Parameters
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.
propertiesProperties to set to the allocated ImageView. If null, default properties are generated.
metadataMetadata to set to the allocated ImageView
Exceptions
ErrorIf given properties are not compatible with given shape and type

◆ assembleChannels()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::assembleChannels ( std::shared_ptr< ImageView image)
static

Adapt a N dimensions scalar ImageView into a N-1 dimensions vectorial one.

No memory is allocated by this operation.

Capabilities of returned ImageView will be restricted to (see ImageCapability):

  • READ

It packs the values of CHANNEL dimension (or the last dimension if does not exist) into one sample vector. The dimension of this vector will be the size of the last dimension of the source ImageView.

Parameters
imageThe source ImageView
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf properties of input ImageView are not valid
ErrorIf original ImageView does not support READ capability

◆ copyInMemory()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::copyInMemory ( std::shared_ptr< ImageView image)
static

Copy given image in memory.

Memory is allocated by this operation. Data from original ImageView (if not in memory) are duplicated.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • BUFFER
  • RESHAPE

If the input image already is in memory, return it (no copy are done).

Parameters
imageImage to load
Exceptions
InvalidArgumentIf the source is null
ErrorIf the input ImageView does not support READ capability
InvalidArgumentIf properties of input ImageView are not valid

◆ copyOnDisk() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::copyOnDisk ( std::shared_ptr< ImageView image)
static

Load an image data into a temporary raw file on disk.

The file is created in usual temporary directory and will be automatically deleted from disk when the instance of the returned ImageView is deleted.

Samples are copied chunk by chunk to optimize memory consumption. Maximum chunk size is 1MB.

No memory is allocated by this operation, only disk space is used.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • RESHAPE

Original ImageView data are duplicated. Data from the returned ImageView are not linked to original ImageView.

If given image is already on disk, a copy will be created in spite of all.

Parameters
imageImageView to load on disk
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf properties of input ImageView are not valid
Returns
ImageView on disk

◆ copyOnDisk() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::copyOnDisk ( std::shared_ptr< ImageView image,
const std::string &  dirPath 
)
static

Load an image data into a temporary raw file on disk.

The file will be removed from disk when the instance of the returned ImageView is deleted.

Samples are copied chunk by chunk to optimize memory consumption. Maximum chunk size is 1MB.

No memory is allocated by this operation, only disk space is used.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • RESHAPE

Original ImageView data are duplicated. Data from the returned ImageView are not linked to original ImageView.

If given image is already on disk, a copy will be created in spite of all.

Parameters
imageImageView to load on disk
dirPathpath where temporary file is created (must exist)
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentif given directory path does not exist
InvalidArgumentIf properties of input ImageView are not valid
Returns
ImageView on disk

◆ createOnDisk() [1/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::createOnDisk ( const std::string &  dirPath,
const VectorXu64 shape,
DataType  type 
)
static

Create an image with the data stored into a temporary file (in given folder) on disk in raw.

No memory is allocated by this operation, only disk space is used.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • RESHAPE

The created file is automatically deleted when destroying the image.

Parameters
dirPaththe path to the folder where the temporary file will be created
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.
Exceptions
InvalidArgumentif given directory path does not exist

◆ createOnDisk() [2/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::createOnDisk ( const std::string &  dirPath,
const VectorXu64 shape,
DataType  type,
std::shared_ptr< ImageProperties properties,
std::shared_ptr< MetadataNode metadata 
)
static

Create an image with the data stored into a temporary file (in given folder) on disk in raw.

No memory is allocated by this operation, only disk space is used.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • RESHAPE

The created file is automatically deleted when destroying the image.

Parameters
dirPaththe path to the folder where the temporary file will be created
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.
propertiesProperties to set to the allocated ImageView
metadataMetadata to set to the allocated ImageView
Exceptions
Errorif given properties are not compatible with given shape and type
InvalidArgumentif given directory path does not exist

◆ createOnDisk() [3/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::createOnDisk ( const VectorXu64 shape,
DataType  type 
)
static

Create an image with the data stored into a temporary file on disk in raw.

No memory is allocated by this operation, only disk space is used.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • RESHAPE

The file is created in usual temporary directory and automatically deleted when destroying the image.

Parameters
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.

◆ createOnDisk() [4/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::createOnDisk ( const VectorXu64 shape,
DataType  type,
std::shared_ptr< ImageProperties properties,
std::shared_ptr< MetadataNode metadata 
)
static

Create an image with the data stored into a temporary file on disk in raw.

No memory is allocated by this operation, only disk space is used.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • RESHAPE

The file is created in usual temporary directory and automatically deleted when destroying the image.

Parameters
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.
propertiesProperties to set to the allocated ImageView
metadataMetadata to set to the allocated ImageView
Exceptions
Errorif given properties are not compatible with given shape and type

◆ disassembleChannels()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::disassembleChannels ( std::shared_ptr< ImageView image)
static

Adapt a N dimensions vectorial ImageView into a N+1 dimensions scalar one.

No memory is allocated by this operation.

Capabilities of returned ImageView will be resctriced to (see ImageCapability):

  • READ

It unpacks samples to generate a CHANNEL dimension for each component. This new dimension will have the size of the original sample size. (e.g. disassemble a RGBA 2D ImageView will result into a 3D ImageView with CHANNEL dimension size = 4)

Parameters
imageThe source ImageView
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf view already contains a CHANNEL dimension
InvalidArgumentIf properties of input ImageView are not valid
ErrorIf original ImageView does not support READ capability

◆ extractAdjustedRegion()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::extractAdjustedRegion ( std::shared_ptr< ImageView view,
const RegionXu64 region 
)
static

Creates an ImageView of given region from given view, packing flat dimensions.

Returned ImageView can potentially have a dimension count lesser than original one. It will depend on the required region. If one (or more) dimension of this region has its size equal to 1, this dimension will be skipped in returned ImageView.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE
Parameters
viewOriginal view on which we want to create a sub-region view
regionRegion of the original view that we want to isolate to create a new view
Exceptions
InvalidArgumentIf the view is null
ErrorIf input ImageView has nor READ or WRITE capability
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentIf required region is empty

◆ extractChannel()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::extractChannel ( std::shared_ptr< ImageView view,
size_t  idxChannel 
)
static

Returns an ImageView from another view containing only given channel Index (useful when channel is not clearly identified).

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE
Parameters
viewOriginal view on which we want to isolate given channel
idxChannelChannel index between 0 and dataType dimension - 1
Exceptions
InvalidArgumentIf the view is null
InvalidArgumentIf requested channel index does not exist
InvalidArgumentIf properties of input ImageView are not valid
ErrorIf input image does not support READ or WRITE capability

◆ extractRegion()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::extractRegion ( std::shared_ptr< ImageView view,
const RegionXu64 region 
)
static

Creates an ImageView of given region from given view.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE
Parameters
viewOriginal view on which we want to create a sub-region view
regionRegion of the original view that we want to isolate to create a new view
Exceptions
InvalidArgumentIf the view is null
ErrorIf input ImageView has nor READ or WRITE capability
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentif required region is empty

◆ flip() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::flip ( std::shared_ptr< ImageView image,
ImageDimension  dimension 
)
static

Flip an ImageView following the given dimension.

No memory is allocated by this operation.

Capabilities of returned ImageView will be resctriced to (see ImageCapability):

  • READ
Parameters
imageImageView to flip
dimensionImageDimension used for flipping
Returns
a ImageView flipped following given dimension
Exceptions
InvalidArgumentIf the image is null
ErrorIf input image does not support READ capability
InvalidArgumentIf image type is not known
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentIf image does not contain given dimension

◆ flip() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::flip ( std::shared_ptr< ImageView image,
size_t  dimensionIndex 
)
static

Flip an ImageView following the given dimension.

No memory is allocated by this operation.

Capabilities of returned ImageView will be resctriced to (see ImageCapability):

  • READ
Parameters
imageImageView to flip
dimensionIndexDimension index used for flipping
Returns
a ImageView flipped following given dimension
Exceptions
InvalidArgumentIf the image is null
ErrorIf input image does not support READ capability
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentif dimension count of given image is lesser than given dimension index

◆ fromBuffer() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromBuffer ( const VectorXu64 shape,
DataType  type,
void *  buffer,
size_t  bufferSize 
)
static

Creates an image from existing buffer.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • BUFFER
Parameters
shapeShape of image
typeType of image
bufferUser buffer. Should have at least a size of shape[0]*shape[1]*...*dataType.byteCount() buffer is not handled by this view and the user should carefully manage buffer and view lifetime.
bufferSizeSize of the buffer in bytes.

◆ fromBuffer() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromBuffer ( const VectorXu64 shape,
DataType  type,
void *  buffer,
size_t  bufferSize,
std::shared_ptr< ImageProperties properties,
const std::shared_ptr< MetadataNode metadata 
)
static

Creates an image from existing buffer.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
  • BUFFER
Parameters
shapeShape of image
typeType of image
bufferUser buffer. Should have at least a size of shape[0]*shape[1]*...*dataType.byteCount() buffer is not handled by this view and the user should carefully manage buffer and view lifetime.
bufferSizeSize of the buffer in bytes.
propertiesProperties of image. If null, image will build a default set of properties.
metadataMetadata of image.
Exceptions
InvalidArgument
ErrorIf given properties are not compatible with given shape and type

◆ fromImageView()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromImageView ( std::shared_ptr< ImageView view,
std::shared_ptr< const ImageProperties properties,
std::shared_ptr< const MetadataNode metadata 
)
static

Allows to apply specific properties and metadata to a ImageView without impact on originals.

No memory is allocated by this operation.

Returned ImageView has the same capabilities than original ImageView.

Parameters
viewInput view
propertiesThe new properties used by the returned image view. If null, the returned image view uses a clone of the input view properties.
metadataThe new metadata used by the returned image view (can be null).
Exceptions
InvalidArgumentIf the view is null
Errorif given properties are not compatible with given shape and type

◆ fromRandomAccess() [1/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromRandomAccess ( std::shared_ptr< RandomAccess accessor,
const VectorXu64 shape,
const DataType  type 
)
static

Create an image from a given RandomAccess.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE

Here the Memory layout is defaulted to Fortan.

Parameters
accessorThe RandomAccess from which reading data
shapeThe shape of the image to create
typeThe data type of the image
Exceptions
InvalidArgumentif accessor is null
Errorif the storage cannot contain a raw image with given shape and datatype

◆ fromRandomAccess() [2/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromRandomAccess ( std::shared_ptr< RandomAccess accessor,
const VectorXu64 shape,
const DataType  type,
std::shared_ptr< ImageProperties properties,
std::shared_ptr< const MetadataNode metadata 
)
static

Create an image from a given RandomAccess.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE

Here the Memory layout is defaulted to Fortan.

Parameters
accessorThe RandomAccess from which reading data
shapeThe shape of the image to create
typeThe data type of the image
propertiesThe properties to attach to the image. If null, default properties are generated.
metadataA set of metadata to attach to the image
Exceptions
InvalidArgumentif accessor is null
Errorif the storage cannot contain a raw image with given shape and datatype
Errorif given properties are not compatible with given shape and type

◆ fromRandomAccess() [3/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromRandomAccess ( std::shared_ptr< RandomAccess accessor,
MemoryLayout  layout,
const VectorXu64 shape,
const DataType  type 
)
static

Create an image from a RandomAccess.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
Parameters
accessorThe RandomAccess from which reading data
layoutThe memory layout to use
shapeThe shape of the image to create
typeThe data type of the image
Exceptions
InvalidArgumentif accessor is null

◆ fromRandomAccess() [4/4]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::fromRandomAccess ( std::shared_ptr< RandomAccess accessor,
MemoryLayout  layout,
const VectorXu64 shape,
const DataType  type,
std::shared_ptr< ImageProperties properties,
const std::shared_ptr< const MetadataNode metadata 
)
static

Create an image from a RandomAccess.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ
  • WRITE
Parameters
accessorThe RandomAccess from which reading data
layoutThe memory layout to use
shapeThe shape of the image to create
typeThe data type of the image
propertiesThe properties to attach to the image. If null, default properties are generated.
metadataA set of metadata to attach to the image
Exceptions
InvalidArgumentif accessor is null
ErrorIf given properties are not compatible with given shape and type

◆ interlace() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::interlace ( std::shared_ptr< MultiImageView multiView)
static

Interlace frames of a MultiImageView into an ImageView.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on capabilities of ImageViews contained in the multiImageView, and be resctriced to (see ImageCapability):

  • READ
  • WRITE

Frames contained in MultiImageViews are assembled to create an ImageView whose samples are the concatenation of samples from original ImageViews. i.e. 3 grayscale ImageViews with UINT16 datatype contained in a multiImageView First ImageView contains ABCDEFG..... values Second ImageView contains abcdefg... values Third ImageView contains 123456.... values Interlace operation gives an ImageViews with VEC3UINT16 datatype whose content is: Aa1 Bb2 Cc3 Dd4 Ee5 Ff6 Gg7.....

Final interlaced ImageView will have Write access only if all original ImageViews (in multiImageView) have Write access

Parameters
multiViewMultiImageView which contains ImageViews to interlace
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf multiImageView contains incompatible ImageViews (different shape or datatypes)
InvalidArgumentIf one frame from multiImageView contains a CHANNEL dimension
InvalidArgumentIf type of at least one frame is not scalar

◆ interlace() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::interlace ( std::shared_ptr< MultiImageView multiView,
ImageInterpretation  newInterpretation,
bool  hasAlpha 
)
static

Interlace frames of a MultiImageView into an ImageView.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on capabilities of ImageViews contained in the multiImageView, and be resctriced to (see ImageCapability):

  • READ
  • WRITE

Frames contained in MultiImageViews are assembled to create an ImageView whose samples are the concatenation of samples from original ImageViews. i.e. 3 grayscale ImageViews with UINT16 datatype contained in a multiImageView First ImageView contains ABCDEFG..... values Second ImageView contains abcdefg... values Third ImageView contains 123456.... values Interlace operation gives an ImageViews with VEC3UINT16 datatype whose content is: Aa1 Bb2 Cc3 Dd4 Ee5 Ff6 Gg7.....

Final interlaced ImageView will have Write access only if all original ImageViews (in multiImageView) have Write access

Parameters
multiViewMultiImageView which contains ImageViews to interlace
newInterpretationinterpretation to set for the interlaced ImageView (default is UNKNOWN)
hasAlphaindicates if the interlaced ImageView contains an Alpha channel (default is FALSE)
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf multiImageView contains incompatible ImageViews (different shape or datatypes)
InvalidArgumentIf one frame from multiImageView contains a CHANNEL dimension
InvalidArgumentIf type of at least one frame is not scalar

◆ makeThreadSafe()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::makeThreadSafe ( std::shared_ptr< ImageView image)
static

Make an ImageView threadsafe.

No memory is allocated by this operation.

Capabilities of returned ImageView will be the same than original image's.

Parameters
imageImageView to make threadsafe
Returns
an ImageView protected for multi-thread accesses.
Exceptions
InvalidArgumentIf the image is null

◆ reinterpret()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::reinterpret ( std::shared_ptr< ImageView image,
ImageType  newImageType 
)
static

Reinterpret an ImageView with a new ImageTypeId.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on capabilities of input ImageView and be resctriced to (see ImageCapability):

  • READ
  • WRITE

It allows to modify the interpretation (VOLUME, IMAGE SEQUENCE, ...) of an any-dimension image. It does not change samples data reading, only image properties. When new interpretation is given, a quick check is done to verify compatibility with given ImageView. (number of dimensions should match with new interpretation)

Specific case: ImageType::UNKNOWN can be set for any given ImageView without error

Exceptions
InvalidArgumentIf the image is null
ErrorIf ImageType is incompatible with ImageView dimension
Parameters
imageImageView whose interpretation must be changed
newImageTypeImage interpretation to apply to image
Returns
a ImageView with new properties to match new image interpretation
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf properties of input ImageView are not valid
ErrorIf new imageType is not comparible with given ImageView

◆ reinterpretAxes() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::reinterpretAxes ( std::shared_ptr< ImageView image,
const ImageDimension dimensionsList,
size_t  count 
)
static

Reinterpret an ImageView by identifying each dimension (axis).

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on capabilities of input ImageView and be resctriced to (see ImageCapability):

  • READ
  • WRITE
Parameters
imageImageView to reinterpret
dimensionsListOrdered list of dimensions to affect to ImageView
countNumber of elements in the given list
Returns
a ImageView where dimensions are potentially reordered to match canonical order and with a new ImageTypeId
Exceptions
InvalidArgumentIf the image is null
ErrorIf dimensionsList size does not match with image dimension.
InvalidArgumentIf properties of input ImageView are not valid

◆ reinterpretAxes() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::reinterpretAxes ( std::shared_ptr< ImageView image,
std::initializer_list< ImageDimension dimensionsList 
)
static

Reinterpret an ImageView by identifying each dimension (axis).

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on capabilities of input ImageView and be resctriced to (see ImageCapability):

  • READ
  • WRITE

It allows to modify the interpretation (VOLUME, IMAGE SEQUENCE, ...) of an any-dimension image by directly affecting an interpretation to each dimension.

It can impact the way samples are read/written, because, according to given ImageDimension list, dimensions will be reordered to match IOLink canonical order (see ImageTypeId)

For example, an 3D ImageView with following list is given (ROW, SLICE, COLUMN). Dimensions will be relocated to match canonical order (COLUMN, ROW, SLICE).

If canonical order is already respected in given list, this will only affect the properties of the ImageView. A quick check is done to verify compatibility with given ImageView. (number of dimensions should match with the given list size). An exception is raised in case of incompatibility.

Warning: never insert a dimension more than once in given list, otherwise the behavior is unpredictable.

This method can be useful for ImageViews based on user memory data, with different dimensions order, and without original interpretation.

Parameters
imageImageView to reinterpret
dimensionsListordered list of dimensions to affect to ImageView
Returns
an ImageView where dimensions are potentially reordered to match canonical order and with a new ImageTypeId
Exceptions
InvalidArgumentIf the image is null
ErrorIf dimensionsList size does not match with image dimension.
InvalidArgumentIf properties of input ImageView are not valid

◆ stack() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::stack ( std::shared_ptr< MultiImageView view)
static

Creates an ImageView from a multiImageView by agglomerating frames into a new unidentified dimension.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageViews contained in MultiImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE

(i.e. a given multiImageView containing 2D ImageViews will give as result 3D ImageView - containing all the images) Concatenation of frames is possible only if their shapes and datatypes are equal. New dimension is always created in last position. e.g.: 3 frames with shapes (5, 6) will be stacked into an 3D Image with shape (5, 6, 3)

This method can be used with frames whose ImageType is not UNKNOWN, but as the new dimension is not given, the ImageType will be lost (UNKNOWN) in output ImageView.

Parameters
viewMultiImage view which contains frames of same format and shape
Exceptions
InvalidArgumentIf the view is null
InvalidArgumentif all frames don't have same shape and datatype

◆ stack() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::stack ( std::shared_ptr< MultiImageView view,
ImageDimension  newDimension 
)
static

Creates an ImageView from a multiImageView by agglomerating frames into a new given dimension.

No memory is allocated by this operation.

Capabilities of returned ImageView will depend on original ImageViews contained in MultiImageView, and will be restricted to (see ImageCapability):

  • READ
  • WRITE

(i.e. a given multiImageView containing 2D frames (with Imagetype = IMAGE) and a given dimension equal to SEQUENCE will give as result a IMAGE_SEQUENCE - video - containing all the images) Concatenation of frames is possible only if their shapes, datatypes and ImageTypes are equal.

A warning will be raised if given frames have an ImageType = UNKNOWN, because the given ImageDimension is ignored in this case, but the stack is still applied, and output ImageType will be UNKNOWN

Parameters
viewMultiImage view which contains frames of same format and shape
newDimensioninterpretation of the new dimension to create
Exceptions
InvalidArgumentIf the view is null
InvalidArgumentif all frames don't have same shape and datatype
InvalidArgumentif given new dimension already exist in given frames
InvalidArgumentif all frames don't have the same interpretation of axes

◆ subSample()

static std::shared_ptr<ImageView> iolink::ImageViewFactory::subSample ( std::shared_ptr< ImageView image,
size_t  step 
)
static

Create a sub-sampled imageView from original.

No memory is allocated by this operation.

Capabilities of returned ImageView will be resctriced to (see ImageCapability):

  • READ
Parameters
imageImageView to sub-sample
steplevel of sub-sampling to apply

New ImageView is created by picking one sample for every step samples of original ImageView. A step of 1 will give the same Image as the original

Returns
a Sub-Sampled ImageView from original ImageView
Exceptions
InvalidArgumentIf the image is null
InvalidArgumentIf properties of input ImageView are not valid
InvalidArgumentIf step is 0 or not compatible with ImageView shape
ErrorIf input image does not support READ capability

◆ uniform() [1/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::uniform ( const VectorXu64 shape,
DataType  type,
void *  value 
)
static

Create an image with uniform value.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ

This image doesn't consume memory, so you can create an image as big as you want.

Parameters
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.
valueBuffer should correspond to given DataType. If null is given, image is filled with zeros.

◆ uniform() [2/2]

static std::shared_ptr<ImageView> iolink::ImageViewFactory::uniform ( const VectorXu64 shape,
DataType  type,
void *  value,
std::shared_ptr< ImageProperties properties,
std::shared_ptr< const MetadataNode metadata 
)
static

Create an image with uniform value.

No memory is allocated by this operation.

Returned ImageView has following capabilities (see ImageCapability):

  • READ

This image doesn't consume memory, so you can create an image as big as you want.

Parameters
shapeThe shape of the image (its dimension and sizes in all dimensions)
typeThe type of data contained in that view.
valueBuffer should correspond to given DataType. If null is given, image is filled with zeros.
propertiesOptional properties. If null, default properties are generated.
metadataOptional metadata. If null, no metadata are generated.
Exceptions
InvalidArgumentIf given properties are not compatible with given shape and type

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