ImFusion SDK 4.3
SharedImageSet Class Reference

#include <ImFusion/GL/SharedImageSet.h>

Set of images independent of their storage location. More...

+ Inheritance diagram for SharedImageSet:

Detailed Description

Set of images independent of their storage location.

This class is the main high-level container for image data consisting of one or multiple images or volumes, and should be used both in algorithms and visualization classes. Both a single focus and multiple selection is featured, as well as providing transformation matrices and timestamps for each image.

SharedImageSet uses shared_ptr internally to store the SharedImages. This enables you to easily create a container SharedImageSet that temporarily wraps existing images (e.g. to pass them to a separate Algorithm) without taking exclusive ownership.

See also
Using Image Data ,
Examples
DicomExtensionExample2.cpp, ExampleAlgorithm.cpp, ExampleAlgorithm.h, NetworkCommunication.cpp, SqrtAlgorithm.cpp, and SqrtAlgorithm.h.

Public Types

enum  CloneOptions {
  Everything = 0 , NoImageData = 1 << 0 , NoDataComponents = 1 << 1 , ShallowImageCopy = 1 << 2 ,
  NoSelection = 1 << 3 , NoTracking = 1 << 4
}
 Bitset enumeration to configure which aspects of a SharedImageSet to copy. More...
 
- Public Types inherited from Data
enum  Kind {
  UNKNOWN = 0 , IMAGE = 1 , VOLUME = 2 , IMAGESET = 3 ,
  VOLUMESET = 4 , IMAGESTREAM = 5 , VOLUMESTREAM = 6 , POINTSET = 7 ,
  SURFACE = 8 , TRACKINGSTREAM = 9 , LIVETRACKINGSTREAM = TRACKINGSTREAM , TRACKINGDATA = 10 ,
  TREE = 11 , TENSOR = 12 , POLYDATASTREAM = 13 , STEREOIMAGESET = 14 ,
  STEREOIMAGESTREAM = 15 , VOLUMETRICMESH = 16
}
 Kind of data. More...
 
enum  Modality {
  NA = 0 , XRAY = 1 , CT = 2 , MRI = 3 ,
  ULTRASOUND = 4 , VIDEO = 5 , NM = 6 , OCT = 7 ,
  LABEL = 8 , DISTANCE = 9
}
 Image modality of the data. More...
 

Public Member Functions

 SharedImageSet (std::shared_ptr< Image > img)
 Construct from a single Image.
 
 SharedImageSet (std::shared_ptr< SharedImage > img)
 Construct from a single SharedImage.
 
 SharedImageSet ()
 Construct an empty SharedImageSet.
 
SharedImageSetoperator= (const SharedImageSet &)=delete
 
std::unique_ptr< SharedImageSetclone (Flags< CloneOptions > cloneOptions=Everything) const
 Create a copy of this SharedImageSet instance.
 
void add (std::shared_ptr< Image > img)
 Add a single image to the data set.
 
void add (std::shared_ptr< Image > img, const mat4 &m)
 Add a single image with its transformation matrix.
 
virtual void add (std::shared_ptr< SharedImage > img)
 Add a shared image to the data set.
 
void add (const std::vector< std::shared_ptr< SharedImage > > &images)
 Add a list of shared images.
 
bool replace (int pos, std::shared_ptr< SharedImage > img)
 Replace a particular shared image entry, will not do anything if no image of that index exist yet.
 
virtual void remove (int pos, int count=1)
 Removes images at the specified locations and deletes them if owned.
 
void remove (const SharedImage *img)
 Removes a specific image and deletes it if owned.
 
virtual void clear ()
 Clear all data and delete it if owned.
 
std::string describe () const override
 Short description of the image set.
 
void setModalityOverride (std::optional< Data::Modality > modalityOverride)
 Set a modalityOverride.
 
virtual void setModality (Modality m)
 Set image modality for all frames.
 
Modality modality () const override
 Return the modality of this data.
 
virtual bool isMultiModal () const
 Return true if set contains images of different modalities, false otherwise.
 
virtual void prepare (bool shiftOnly=false)
 Prepare the image in memory for most common scenarios Integral types are converted to unsigned representation if applicable, double-precision will be converted to single-precision float.
 
void uploadGl () const
 Upload all images as OpenGL textures.
 
bool hasMem (int which=-1) const
 Query whether an up-to-date memory image is present. If not, a sync is required.
 
bool hasGl (int which=-1) const
 Query whether an up-to-date OpenGL image is present. If not, a sync is required.
 
const DataComponentListcomponents () const
 Returns the list of DataComponents for this data.
 
DataComponentListcomponents ()
 
const DataComponentListcomponents (int i) const
 Returns the DataComponents associated to the element with that index.
 
- Public Member Functions inherited from Data
 Data (const std::string &name="")
 
 Data (const Data &other)
 
Dataoperator= (const Data &other)
 
virtual ~Data ()
 Mandatory virtual destructor.
 
const std::stringname () const
 Return the name of this data.
 
void setName (const std::string &name)
 Sets the name of this data.
 
virtual bool isAnnotationType () const
 Return whether this data type is visualized through an annotation (e.g. mesh)
 
const DataComponentListcomponents () const
 Returns the list of DataComponents for this data.
 
DataComponentListcomponents ()
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
 
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.
 
- Public Member Functions inherited from ElementwiseDataComponentData
ElementwiseDataComponentListelementwiseComponents ()
 Returns elementwise data component list.
 
const ElementwiseDataComponentListelementwiseComponents () const
 Returns elementwise data component list.
 
DataComponentListmutableComponents (int i)
 Returns the DataComponents associated to the element with that index, creating it if necessary.
 
const DataComponentListcomponents (int i) const
 Returns the DataComponents associated to the element with that index.
 
- Public Member Functions inherited from Selectable
 Selectable (const Selectable &)
 
 Selectable (Selectable &&)
 
Selectableoperator= (const Selectable &)
 
Selectableoperator= (Selectable &&)
 
virtual Selection selection () const
 
virtual int focus () const
 
virtual void setSelection (const Selection &sel)
 Set the underlying selection.
 
virtual void setFocus (int index)
 Set focus of the selection.
 

Protected Member Functions

virtual SharedImageSetcreateCloneContainer () const
 Internal method for creating the container object holding the clone.
 
virtual void cloneInternal (SharedImageSet &other, Flags< CloneOptions > cloneOptions) const
 Internal method for cloning which should be called from derived container classes.
 
virtual void swapWith (SharedImageSet &other)
 Internal method for swapping the contents of this container with other.
 
- Protected Member Functions inherited from Data
void swapWith (Data &other)
 Swaps the data and emits a matrix and name changed signal for both.
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Protected Attributes

std::vector< std::shared_ptr< SharedImage > > m_images
 Vector of shared image pointers.
 
std::vector< double > m_timestamps
 Optional timestamps of the image frames.
 
Properties m_properties
 Auxiliary information properties.
 
Geometry::AlignedBox m_bounds
 Axis-aligned bounding box of all images in world space.
 
bool m_updateBounds = true
 Flag specifying whether the bounds should be re-computed.
 
std::optional< Data::Modalitym_modalityOverride
 Overrides the modality of the containing SharedImages. This is used e.g. for the ConeBeamData concept in CT.
 
- Protected Attributes inherited from Data
mat4 m_matrix
 Transformation matrix.
 
std::recursive_mutexm_matrixMutex
 Used to internally synchronize access to the matrix of data.
 
DataComponentList m_dataComponentList
 The list of DataComponents for this data.
 
- Protected Attributes inherited from ElementwiseDataComponentData
ElementwiseDataComponentList m_elementwiseComponents
 Encodes elementwise data components.
 
- Protected Attributes inherited from Selectable
std::mutex m_selectionMutex
 Mutex protecting the selection.
 
Selection m_sel
 

Image access

virtual SharedImageget (int which=-1)
 Get specific or selected shared image.
 
std::shared_ptr< SharedImagegetShared (int which=-1)
 Get specific or selected shared image.
 
MemImagemem (int which=-1)
 Get specific or selected image in memory If required image will be synchronized.
 
GlImagegl (int which=-1)
 Get specific or selected OpenGL image If required image will be synchronized.
 
const std::vector< std::shared_ptr< SharedImage > > & images ()
 Return entire vector of images.
 
std::vector< std::shared_ptr< SharedImage > > selectedImages (Selection::NonePolicy noneSelectionHandling)
 Return vector of all selected images.
 

Const image access

virtual const SharedImageget (int which=-1) const
 Get specific or selected shared image.
 
std::shared_ptr< const SharedImagegetShared (int which=-1) const
 Get specific or selected shared image.
 
const Imageimg (int which=-1) const
 Get specific or selected image descriptor.
 
const MemImagemem (int which=-1) const
 Get specific or selected image in memory If required image will be synchronized.
 
const GlImagegl (int which=-1) const
 Get specific or selected OpenGL image If required image will be synchronized.
 
std::vector< std::shared_ptr< const SharedImage > > images () const
 Return entire vector of images.
 
std::vector< std::shared_ptr< const SharedImage > > selectedImages (Selection::NonePolicy noneSelectionHandling) const
 Return vector of all selected images.
 

Image matrix access

Pose::TransformationConvention matrixConvention () const override
 Matrices of images map from the world coordinate system.
 
virtual void setMatrix (const mat4 &m, int which, bool updateAll=false)
 Set specific (which >=0) or focused (which ==-1) image matrix.
 
virtual mat4 matrix (int which) const
 Get specific (which >=0) or focused (which ==-1) image matrix.
 
void setMatrix (const mat4 &m) override
 Set focused image matrix.
 
mat4 matrix () const override
 Get focused image matrix.
 
virtual void setMatrixFromWorld (const mat4 &m, int which, bool updateAll=false)
 Set specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system.
 
virtual void setMatrixToWorld (const mat4 &m, int which, bool updateAll=false)
 Set specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system.
 
virtual mat4 matrixFromWorld (int which) const
 Get specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system.
 
virtual mat4 matrixToWorld (int which) const
 Get specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system.
 
virtual bool hasTransformations () const
 Return true if at least one image in the set has a matrix transformation unequal identity.
 
virtual void setDeformation (std::shared_ptr< Deformation > def, int which=-1)
 Sets a deformation for specified or focus image.
 
virtual std::shared_ptr< Deformationdeformation (int which=-1) const
 Returns the deformation for the specified or focused image, or 0 if not deformation is set.
 
virtual void setMask (std::shared_ptr< Mask > mask, int which=-1)
 Sets a mask for specified or focus image.
 
virtual std::shared_ptr< Maskmask (int which=-1) const
 Returns the mask for the specified or focused image, or 0 if not mask is set.
 
virtual mat4 matrixFromWorld () const
 Get matrix mapping from the world coordinate system to the data coordinate system.
 
virtual mat4 matrixToWorld () const
 Get matrix mapping from the data coordinate system to the world coordinate system.
 
virtual void setMatrixFromWorld (const mat4 &m)
 Set matrix mapping from the world coordinate system to the data coordinate system.
 
virtual void setMatrixToWorld (const mat4 &m)
 Set matrix mapping from the data coordinate system to the world coordinate system.
 

Timestamp access

virtual void setTimestamp (double time, int which=-1)
 Set specific or focused timestamp in seconds.
 
double timestamp (int which=-1) const
 Get specific or focused timestamp in seconds.
 
const std::vector< double > timestamps () const
 Get the timestamps sequence.
 
bool hasTimestamps () const
 Return if all image frames have timestamps.
 

Miscellaneous const access methods

int size () const override
 Return the size of the image set.
 
bool allEqual () const
 Return if all image descriptors are the same.
 
Kind kind () const override
 Return the kind of data contained here.
 
Geometry::AlignedBox bounds () const override
 Returns the axis-aligned bounding box of all images in world space.
 
Propertiesproperties ()
 Return auxiliary data structures stored in Properties.
 
const Propertiesproperties () const
 Return auxiliary data structures stored in Properties.
 

Additional Inherited Members

- Static Public Member Functions inherited from Data
static std::string modalityString (Data::Modality m)
 Return the name of an image modality.
 
static Data::Modality stringToModality (const std::string &s)
 Returns the modality corresponding to a modality string or NA if nothing matches.
 
- Public Attributes inherited from Data
Signal< const Data * > signalDeleted
 Signal emitted when this instance is deleted.
 
Signal< const Data * > signalMatrixChanged
 Signal emitted when the transformation of this Data has changed.
 
Signal< std::stringsignalNameChanged
 Signal emitted when the name changed.
 
- Public Attributes inherited from Selectable
ProtectedSignal signalSelectionChanged
 Signals that the selection or size might have changed.
 

Member Enumeration Documentation

◆ CloneOptions

Bitset enumeration to configure which aspects of a SharedImageSet to copy.

Enumerator
Everything 

Perform a deep copy of all data contained by the SharedImageSet.

NoImageData 

Do not clone any image data.

NoDataComponents 

Do not clone any DataComponents.

ShallowImageCopy 

Clone SharedImages with SharedImage::ShallowImageCopy flag (do not deep copy the underlying Images)

NoSelection 

Do not copy over the Selection.

NoTracking 

Do not copy over any TrackingSequences (only relevant for TrackedSharedImageSet derived classes)

Constructor & Destructor Documentation

◆ SharedImageSet() [1/2]

SharedImageSet ( std::shared_ptr< Image > img)
explicit

Construct from a single Image.

Note that any std::unique_ptr implicitly converts to a std::shared_ptr of same type.

◆ SharedImageSet() [2/2]

Construct from a single SharedImage.

Note that any std::unique_ptr implicitly converts to a std::shared_ptr of same type.

Member Function Documentation

◆ add()

virtual void add ( std::shared_ptr< SharedImage > img)
virtual

Add a shared image to the data set.

Reimplemented in TrackedSharedImageSet.

◆ remove() [1/2]

virtual void remove ( int pos,
int count = 1 )
virtual

Removes images at the specified locations and deletes them if owned.

Note
Will notify any attached ElementwiseDataComponent about the removal.

Reimplemented in TrackedSharedImageSet.

◆ remove() [2/2]

void remove ( const SharedImage * img)

Removes a specific image and deletes it if owned.

Note
Will notify any attached ElementwiseDataComponent about the removal.

◆ clear()

virtual void clear ( )
virtual

Clear all data and delete it if owned.

Reimplemented in TrackedSharedImageSet.

◆ describe()

std::string describe ( ) const
overridevirtual

Short description of the image set.

Reimplemented from Data.

◆ setModalityOverride()

void setModalityOverride ( std::optional< Data::Modality > modalityOverride)

Set a modalityOverride.

See SharedImageSet::modality() for more details on how the modality of the SharedImageSet is determined in case of an active modalityOverride.

Parameters
modalityOverridePass a Data::Modality to set a modalityOverride. In order to remove an override you can pass std::nullopt as argument.

◆ modality()

Modality modality ( ) const
overridevirtual

Return the modality of this data.

The modality will be determined like this:

  • If a modalityOverride is set its value will be returned.
  • Otherwise, if all images have the same modality this modality will be returned.
  • In any other case, including an empty SharedImageSet, Data::NA will be returned.

Reimplemented from Data.

Reimplemented in UltrasoundSweep.

◆ prepare()

virtual void prepare ( bool shiftOnly = false)
virtual

Prepare the image in memory for most common scenarios Integral types are converted to unsigned representation if applicable, double-precision will be converted to single-precision float.

Furthermore, if shiftOnly is false it will rescale the present intensity range to [0..1] for floating point types or to the entire available value range for integral types. For image sets that contain more than one image shiftOnly will always be forced to true. Derived classes may do more modality specific processing here.

Note
Pointers to the underlying image data may be invalidated as a result.

◆ uploadGl()

void uploadGl ( ) const

Upload all images as OpenGL textures.

This method throws an exception if the OpenGL texture creation fails.

◆ mem() [1/2]

MemImage * mem ( int which = -1)

Get specific or selected image in memory If required image will be synchronized.

Use hasMem() to check if synchronization is required.

◆ gl() [1/2]

GlImage * gl ( int which = -1)

Get specific or selected OpenGL image If required image will be synchronized.

Use hasGl() to check if synchronization is required.

◆ images()

const std::vector< std::shared_ptr< SharedImage > > & images ( )
inline

Return entire vector of images.

This method is non-const since the images themselves may be manipulated.

◆ mem() [2/2]

const MemImage * mem ( int which = -1) const

Get specific or selected image in memory If required image will be synchronized.

Use hasMem() to check if synchronization is required.

◆ gl() [2/2]

const GlImage * gl ( int which = -1) const

Get specific or selected OpenGL image If required image will be synchronized.

Use hasGl() to check if synchronization is required.

◆ matrixConvention()

Pose::TransformationConvention matrixConvention ( ) const
inlineoverridevirtual

Matrices of images map from the world coordinate system.

Implements Data.

Reimplemented in TrackedSharedImageSet.

◆ setMatrix() [1/2]

virtual void setMatrix ( const mat4 & m,
int which,
bool updateAll = false )
virtual

Set specific (which >=0) or focused (which ==-1) image matrix.

If updateAll is set, the matrices of all images are updated relative to which.

Reimplemented in TrackedSharedImageSet.

◆ matrix() [1/2]

virtual mat4 matrix ( int which) const
virtual

Get specific (which >=0) or focused (which ==-1) image matrix.

Reimplemented in TrackedSharedImageSet.

◆ setMatrix() [2/2]

void setMatrix ( const mat4 & m)
overridevirtual

Set focused image matrix.

Reimplemented from Data.

Reimplemented in TrackedSharedImageSet.

◆ matrix() [2/2]

mat4 matrix ( ) const
overridevirtual

Get focused image matrix.

Reimplemented from Data.

Reimplemented in TrackedSharedImageSet.

◆ setMatrixFromWorld() [1/2]

virtual void setMatrixFromWorld ( const mat4 & m,
int which,
bool updateAll = false )
virtual

Set specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system.

If updateAll is set, the matrices of all images are updated relative to which.

Reimplemented in TrackedSharedImageSet.

◆ setMatrixToWorld() [1/2]

virtual void setMatrixToWorld ( const mat4 & m,
int which,
bool updateAll = false )
virtual

Set specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system.

If updateAll is set, the matrices of all images are updated relative to which.

Reimplemented in TrackedSharedImageSet.

◆ matrixFromWorld() [1/2]

virtual mat4 matrixFromWorld ( int which) const
virtual

Get specific (which >=0) or focused (which ==-1) image matrix mapping from the world coordinate system.

Reimplemented in TrackedSharedImageSet.

◆ matrixToWorld() [1/2]

virtual mat4 matrixToWorld ( int which) const
virtual

Get specific (which >=0) or focused (which ==-1) image matrix mapping to the world coordinate system.

Reimplemented in TrackedSharedImageSet.

◆ hasTransformations()

virtual bool hasTransformations ( ) const
virtual

Return true if at least one image in the set has a matrix transformation unequal identity.

Reimplemented in TrackedSharedImageSet.

◆ setTimestamp()

virtual void setTimestamp ( double time,
int which = -1 )
virtual

Set specific or focused timestamp in seconds.

Reimplemented in TrackedSharedImageSet.

◆ size()

int size ( ) const
overridevirtual

Return the size of the image set.

Implements Selectable.

◆ kind()

Kind kind ( ) const
overridevirtual

Return the kind of data contained here.

Implements Data.

◆ bounds()

Geometry::AlignedBox bounds ( ) const
overridevirtual

Returns the axis-aligned bounding box of all images in world space.

Implements Data.

Reimplemented in TrackedSharedImageSet, and UltrasoundSweep.

◆ properties() [1/2]

Properties * properties ( )

Return auxiliary data structures stored in Properties.

Note
Prefer using DataComponents as type-safe alternative if possible.

◆ properties() [2/2]

const Properties * properties ( ) const

Return auxiliary data structures stored in Properties.

Note
Prefer using DataComponents as type-safe alternative if possible.

◆ createCloneContainer()

virtual SharedImageSet * createCloneContainer ( ) const
protectedvirtual

Internal method for creating the container object holding the clone.

Reimplemented in TrackedSharedImageSet, and UltrasoundSweep.

◆ cloneInternal()

virtual void cloneInternal ( SharedImageSet & other,
Flags< CloneOptions > cloneOptions ) const
protectedvirtual

Internal method for cloning which should be called from derived container classes.

Reimplemented in TrackedSharedImageSet.

◆ matrixFromWorld() [2/2]

virtual mat4 matrixFromWorld ( ) const
virtual

Get matrix mapping from the world coordinate system to the data coordinate system.

Inverse of matrixToWorld.

Note
Depending on how matrices are internally stored in concrete derived classes, a matrix inversion might be necessary to obtain this mapping. The default implementation checks matrixConvention and accordingly returns matrix or its inverse.

Reimplemented from Data.

◆ matrixToWorld() [2/2]

virtual mat4 matrixToWorld ( ) const
virtual

Get matrix mapping from the data coordinate system to the world coordinate system.

Inverse of matrixFromWorld.

Note
Depending on how matrices are internally stored in concrete derived classes, a matrix inversion might be necessary to obtain this mapping. The default implementation checks matrixConvention and accordingly returns matrix or its inverse.

Reimplemented from Data.

◆ setMatrixFromWorld() [2/2]

virtual void setMatrixFromWorld ( const mat4 & m)
virtual

Set matrix mapping from the world coordinate system to the data coordinate system.

Note
Depending on how matrices are internally stored in concrete derived classes, m might be inverted before it is saved. The default implementation checks matrixConvention and accordingly calls setMatrix with either m or its inverse.

Reimplemented from Data.

◆ setMatrixToWorld() [2/2]

virtual void setMatrixToWorld ( const mat4 & m)
virtual

Set matrix mapping from the data coordinate system to the world coordinate system.

Note
Depending on how matrices are internally stored in concrete derived classes, m might be inverted before it is saved. The default implementation checks matrixConvention and accordingly calls setMatrix with either m or its inverse.

Reimplemented from Data.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close