![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/MemImage.h>
Abstract base class for an image residing in main memory. More...
Inheritance diagram for MemImage:Abstract base class for an image residing in main memory.
Use the templated TypedImage to instantiate a MemImage for a concrete pixel type.
Public Types | |
| enum class | Ownership { NotOwning = 0 , Owning = 1 } |
| Enumeration to describe image data pointer ownership. More... | |
Public Types inherited from Image | |
| enum | Type { BYTE = static_cast<int>(PixelType::Byte) , UBYTE = static_cast<int>(PixelType::UByte) , SHORT = static_cast<int>(PixelType::Short) , USHORT = static_cast<int>(PixelType::UShort) , INT = static_cast<int>(PixelType::Int) , UINT = static_cast<int>(PixelType::UInt) , FLOAT = static_cast<int>(PixelType::Float) , DOUBLE = static_cast<int>(PixelType::Double) , HFLOAT = static_cast<int>(PixelType::HFloat) } |
| Pixel/voxel data type, equivalent to OpenGL defines. More... | |
| enum | Location { NONE = 0 , MEMORY = 1 , OPENGL = 2 , OPENCL = 3 , CUSTOM = 6 } |
| Location where the data resides. More... | |
Public Member Functions | |
| std::unique_ptr< MemImage > | clone () const |
| Create a deep copy of the image. | |
| virtual bool | update (const MemImage &img)=0 |
| Update image data. | |
| template<typename T> | |
| TypedImage< T > * | typed () |
Convenience function to perform a dynamic_cast<TypedImage<T>> of this instance. | |
| template<typename T> | |
| const TypedImage< T > * | typed () const |
| Location | location () const override |
| Specifies that the image resides in main memory. | |
| bool | load (const std::string &filename, int64_t offset=0) |
| Loads the image content from a file, returns true if successful. | |
| bool | save (const std::string &filename) const |
| Saves the image content to a file, returns true if successful. | |
| virtual const void * | data () const =0 |
| Returns a void pointer to the underlying raw pixel buffer of the image. | |
| virtual void * | data ()=0 |
| virtual double | valueDouble (size_t index) const =0 |
| Return the pixel intensity at the given index without interpolation casted to double. | |
| virtual double | valueDouble (int x, int y, int z=0, int c=0) const =0 |
| Return the pixel intensity at the coordinate without interpolation casted to double. | |
| virtual double | valueDouble (double x, double y, double z=0, int c=0, bool clamp=true, bool *valid=nullptr) const =0 |
| Return the pixel intensity at the given coordinate using linear interpolation casted to double. | |
| virtual void | setValueDouble (double value, size_t index) const =0 |
| Set the pixel intensity at the given index to value casted to the underlying type without any clamping or normalization. | |
| virtual void | setValueDouble (double value, int x, int y, int z=0, int c=0) const =0 |
| Set the pixel intensity at the given coordinate to value casted to the underlying type without any clamping or normalization. | |
| std::pair< double, double > | getRangeDouble () const |
| Computes the minimum and maximum image intensity of the entire image casted to double. | |
| virtual void | getRangeDouble (double &minVal, double &maxVal) const =0 |
| std::unique_ptr< MemImage > | getSliceView (int slice) const |
| Extract a MemImage representing a view onto the specified slice of this image. | |
| virtual void | fillDouble (double value)=0 |
| Fill image with the given double value for all channels and pixels. | |
| virtual void | fillDouble (const std::vector< double > &channelValues)=0 |
| Fill image with the given double channel values for all pixels. | |
Public Member Functions inherited from Image | |
| Image (const ImageDescriptor &desc) | |
| Create a new Image with the given descriptor. | |
| Image (const Image &other)=default | |
| Image & | operator= (const Image &other)=default |
| Image (Image &&other) noexcept=default | |
| Image & | operator= (Image &&other) noexcept=default |
| const ImageDescriptor & | descriptor () const |
| Return the image descriptor. | |
| void | configure (const Properties *p) override |
| Configure the image descriptor from properties. | |
| void | configuration (Properties *p) const override |
| Store image descriptor into properties. | |
| void | setShift (double val) |
| Sets the intensity shift value. | |
| void | setScale (double val) |
| Sets the intensity scale value. | |
| void | setSpacing (double sx, double sy, double sz=1.0) |
| Specify pixel/voxel spacing with two or three scalar values. | |
| void | setSpacing (double sx, double sy, double sz, bool isMetric) |
| Convenience function for specifying spacing and metric flag at the same time. | |
| void | setSpacing (const vec3 &s) |
| Specify pixel/voxel spacing using a 3-vector. | |
| void | setSpacing (const vec3 &s, bool metric) |
| Convenience function for specifying spacing and metric flag at the same time. | |
| void | setMetric (bool val) |
| Set data to be metric. | |
| double | storageToOriginal (double value) const |
| Applies the image's shift and scale in order to convert value from storage pixel value domain to original pixel value domain. | |
| double | originalToStorage (double value) const |
| Applies the image's shift and scale in order to convert value from original pixel value domain to storage pixel value domain. | |
| PixelType | pixelType () const |
| Returns the data type of the image. | |
| Type | type () const |
| Returns the data type of the image. | |
| int | width () const |
| Returns the width of the image. | |
| int | height () const |
| Returns the height of the image. | |
| int | slices () const |
| Returns the number of 3D slices of the image. | |
| int | channels () const |
| Returns the number of channels of the image. | |
| double | shift () const |
| Returns the intensity shift. | |
| double | scale () const |
| Returns the intensity scale. | |
| vec3 | spacing () const |
| Returns pointer to the pixel/voxel spacing values. | |
| bool | isMetric () const |
| Returns true if data is metric. | |
| vec3 | extent () const |
| Returns the physical size of the image as a vector. | |
| vec3i | dimensions () const |
| Returns the dimensions of the image in pixels as a vector. | |
| vec3 | pixelToImage (const vec3 &pixel) const |
| Convert a 3D pixel/voxel position to image coordinates. | |
| vec3 | imageToPixel (const vec3 &world) const |
| Convert 3D image coordinates to pixel/voxel position. | |
| mat4 | pixelToImageMatrix () const |
| Returns a 4x4 matrix to transform from image pixel space to image space. | |
| mat4 | imageToPixelMatrix () const |
| Returns a 4x4 matrix to transform from image space to image pixel space. | |
| size_t | index (int x, int y, int z=0, int c=0) const |
| Returns a linear memory index for a pixel or voxel. | |
| bool | hasIndex (int x, int y, int z=0, int c=0) const |
| Returns true if the pixel at (x,y,z) exists, false otherwise. | |
| vec4i | coord (size_t index) const |
| Returns the pixel/voxel coordinate (x,y,z,c) for a given index. | |
| size_t | size () const |
| Returns the size (number of elements) of the image. | |
| int | typeSize () const |
| Return the nominal size in bytes of standard data types, zero if unknown. | |
| bool | isInteger () const |
| Returns whether the image is of an integer data type. | |
| bool | isSigned () const |
| Returns whether the image type supports negative values. | |
| size_t | byteSize () const |
| Returns the size of the image in bytes. | |
| int | alignment () const |
| Returns the byte alignment of an image line (up to 8) | |
| int | dimension () const |
| Returns the spatial dimension of the image. | |
| bool | compatible (const Image &other, bool ignoreType=false, bool ignore3D=false, bool ignoreChannels=false) const |
| Tells if this image is compatible to another one. | |
Public Member Functions inherited from Configurable | |
| virtual void | configureDefaults () |
| Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
| void | registerParameter (ParameterBase *param) |
| Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
| void | unregisterParameter (const ParameterBase *param) |
| Remove the given Parameter or SubProperty from the list of registered parameters. | |
| Configurable (const Configurable &rhs) | |
| Configurable (Configurable &&rhs) noexcept | |
| Configurable & | operator= (const Configurable &) |
| Configurable & | operator= (Configurable &&) noexcept |
Static Public Member Functions | |
| static std::unique_ptr< MemImage > | create (const ImageDescriptor &descriptor) |
| Factory method to instantiate a MemImage from an ImageDescriptor. | |
| static std::unique_ptr< MemImage > | create (const ImageDescriptor &descriptor, void *data, Ownership own=Ownership::NotOwning) |
| Factory method to instantiate a MemImage from an ImageDescriptor and pointer to existing image data. | |
| static std::unique_ptr< MemImage > | zeros (const ImageDescriptor &descriptor) |
| Factory method to create a zero-initialized image. | |
Protected Member Functions | |
| MemImage (MemImage &&other) noexcept | |
| MemImage & | operator= (MemImage &&other) noexcept |
| MemImage (const MemImage &other)=delete | |
| MemImage & | operator= (const MemImage &other)=delete |
| MemImage (const ImageDescriptor &desc) | |
| virtual MemImage * | cloneImpl () const =0 |
| virtual std::unique_ptr< MemImage > | getSliceViewImpl (int slice) const =0 |
Protected Member Functions inherited from Image | |
| template<typename T> | |
| bool | typeCompatible () const |
Deprecated Interface | |
| virtual std::unique_ptr< MemImage > | prepare (bool msb=false, bool shiftOnly=false)=0 |
| Optimal rescaling and conversion to unsigned data type if applicable. | |
| virtual std::unique_ptr< MemImage > | unscaled () const =0 |
| Return copy of this image with intensity scale and shift undone, if necessary. | |
Additional Inherited Members | |
Public Attributes inherited from Configurable | |
| Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
Protected Attributes inherited from Image | |
| ImageDescriptor | m_descriptor |
Protected Attributes inherited from Configurable | |
| std::vector< Param > | m_params |
| List of all registered Parameter and SubProperty instances. | |
|
strong |
|
static |
Factory method to instantiate a MemImage from an ImageDescriptor.
|
static |
Factory method to instantiate a MemImage from an ImageDescriptor and pointer to existing image data.
Will internally dispatch to TypedImage<T>::create() based on the pixel type of descriptor.
| descriptor | ImageDescriptor of the new image. |
| data | Pointer to image data, must match the descriptor layout. |
| own | Flag whether the newly created image shall take ownership of data. |
|
pure virtual |
Update image data.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
| TypedImage< T > * typed | ( | ) |
Convenience function to perform a dynamic_cast<TypedImage<T>> of this instance.
Returns nullptr if image is not of type T.
|
inlineoverridevirtual |
Specifies that the image resides in main memory.
Reimplemented from Image.
|
pure virtual |
Returns a void pointer to the underlying raw pixel buffer of the image.
TypedImage<T> specialization provides pointer() as type-safe alternative. Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Return the pixel intensity at the given index without interpolation casted to double.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Return the pixel intensity at the coordinate without interpolation casted to double.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Return the pixel intensity at the given coordinate using linear interpolation casted to double.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Set the pixel intensity at the given index to value casted to the underlying type without any clamping or normalization.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Set the pixel intensity at the given coordinate to value casted to the underlying type without any clamping or normalization.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
| std::unique_ptr< MemImage > getSliceView | ( | int | slice | ) | const |
Extract a MemImage representing a view onto the specified slice of this image.
The returned image only points to the data and does not own it. It is therefore only valid as long this image is valid. Returns nullptr if slice is out of range.
|
pure virtual |
Fill image with the given double value for all channels and pixels.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Fill image with the given double channel values for all pixels.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Optimal rescaling and conversion to unsigned data type if applicable.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.
|
pure virtual |
Return copy of this image with intensity scale and shift undone, if necessary.
The method returns a zero pointer if there is no scale and shift and if the image has a floating-point data type.
Implemented in TypedImage< T >, TypedImage< float >, TypedImage< int >, TypedImage< uint8_t >, TypedImage< unsigned char >, and TypedImage< unsigned short >.