![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/TypedImage.h>
Concrete implementation of a MemImage for a given pixel type. More...
Inheritance diagram for TypedImage< T >:Concrete implementation of a MemImage for a given pixel type.
A TypedImage is movable but not copyable. Use clone() in order to perform a deep copy.
Public Types | |
| using | value_type = T |
Public Types inherited from MemImage | |
| 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 | |
| TypedImage (const ImageDescriptor &descriptor, T *data=nullptr, Ownership own=Ownership::NotOwning) | |
| Create a new TypedImage from an ImageDescriptor. | |
| TypedImage (const vec3i &dimensions, int numChannels=1, T *data=nullptr, Ownership own=Ownership::NotOwning) | |
| Create a new TypedImage with given dimensions and channels. | |
| TypedImage (const TypedImage &)=delete | |
| TypedImage & | operator= (const TypedImage &)=delete |
| TypedImage (TypedImage &&other) noexcept | |
| TypedImage & | operator= (TypedImage &&other) noexcept |
| std::unique_ptr< TypedImage< T > > | clone () const |
| Create a deep copy of the image. | |
| bool | update (const TypedImage< T > &other) |
| Update image data pointed to by this object. If the other image is not compatible with the current one the image is resized. | |
| bool | update (const MemImage &other) override |
| Update image data pointed to by this object. | |
| bool | update (const std::vector< T > &data) |
| Update image data using non-image buffer. Data arrangement in this buffer is assumed to match the target image. | |
| bool | update (const T *data) |
| More generic and somewhat less secure version of the above method. | |
| void | fill (T value) |
| Fill image with the given constant value for all channels and pixels. | |
| void | fill (const std::vector< T > &channelValues) |
| Fill image with the given channel values for all pixels. | |
| void | fillDouble (double value) override |
| Fill image with the given double value for all channels and pixels. | |
| void | fillDouble (const std::vector< double > &channelValues) override |
| Fill image with the given double channel values for all pixels. | |
| const T * | pointer () const |
| Returns a typed pointer to the underlying raw pixel buffer of the image. | |
| T * | pointer () |
| const void * | data () const override |
| Returns a void pointer to the underlying raw pixel buffer of the image. | |
| void * | data () override |
| T | value (int x, int y, int z=0, int c=0) const |
| Return the pixel intensity at the coordinate without interpolation. | |
| T | value (size_t index) const |
| Return the pixel intensity at the index without interpolation. | |
| double | valueDouble (size_t index) const override |
| Return the pixel intensity at the given index without interpolation casted to double. | |
| double | valueDouble (int x, int y, int z=0, int c=0) const override |
| Return the pixel intensity at the coordinate without interpolation casted to double. | |
| double | valueDouble (double x, double y, double z=0, int c=0, bool clamp=true, bool *valid=nullptr) const override |
| Return the pixel intensity at the given coordinate using linear interpolation casted to double. | |
| void | setValue (T value, int x, int y, int z=0, int c=0) |
| Set the pixel intensity at the given coordinate to value. | |
| void | setValueDouble (double value, size_t index) const override |
| Set the pixel intensity at the given index to value casted to the underlying type without any clamping or normalization. | |
| void | setValueDouble (double value, int x, int y, int z=0, int c=0) const override |
| Set the pixel intensity at the given coordinate to value casted to the underlying type without any clamping or normalization. | |
| std::pair< T, T > | getRange () const |
| Computes the minimum and maximum image intensity of the entire image. | |
| void | getRange (T &minVal, T &maxVal) const |
| void | getRangeDouble (double &minVal, double &maxVal) const override |
| Computes the minimum and maximum image intensity of the entire image casted to double. | |
| std::unique_ptr< TypedImage< T > > | getSliceView (int slice) const |
| Extract a MemImage representing a view onto the specified slice of this image. | |
| std::pair< double, double > | getRangeDouble () const |
| Computes the minimum and maximum image intensity of the entire image casted to double. | |
Public Member Functions inherited from MemImage | |
| std::unique_ptr< MemImage > | clone () const |
| Create a deep copy of the image. | |
| 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. | |
| std::pair< double, double > | getRangeDouble () const |
| Computes the minimum and maximum image intensity of the entire image casted to double. | |
| std::unique_ptr< MemImage > | getSliceView (int slice) const |
| Extract a MemImage representing a view onto the specified slice of this image. | |
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< TypedImage< T > > | create (const ImageDescriptor &descriptor, T *data=nullptr, Ownership own=Ownership::NotOwning) |
| Factory method to create a new TypedImage from an ImageDescriptor. | |
| static std::unique_ptr< TypedImage< T > > | create (const vec3i &dimensions, int numChannels=1, T *data=nullptr, Ownership own=Ownership::NotOwning) |
| Factory method to create a new TypedImage of given dimensions and number of channels. | |
| static std::unique_ptr< TypedImage< T > > | zeros (const ImageDescriptor &descriptor) |
| Factory method to create a zero-initialized image, pixel type in descriptor is ignored. | |
| static std::unique_ptr< TypedImage< T > > | zeros (const vec3i &dimensions, int numChannels=1) |
| Factory method to create a zero-initialized image of given dimensions and number of channels. | |
Static Public Member Functions inherited from MemImage | |
| 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 | |
| TypedImage< T > * | cloneImpl () const override |
| std::unique_ptr< MemImage > | getSliceViewImpl (int slice) const override |
Protected Member Functions inherited from MemImage | |
| MemImage (MemImage &&other) noexcept | |
| MemImage & | operator= (MemImage &&other) noexcept |
| MemImage (const MemImage &other)=delete | |
| MemImage & | operator= (const MemImage &other)=delete |
| MemImage (const ImageDescriptor &desc) | |
Protected Member Functions inherited from Image | |
| template<typename T> | |
| bool | typeCompatible () const |
Protected Attributes | |
| T * | m_data |
| Pointer to the actual image data. | |
| Ownership | m_own |
| Do we own the data (i.e. container mode if false) | |
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. | |
Deprecated Interface | |
| std::unique_ptr< MemImage > | prepare (bool msb=false, bool shiftOnly=false) override |
| Optimal rescaling and conversion to unsigned data type if applicable. | |
| std::unique_ptr< MemImage > | unscaled () const override |
| 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. | |
| TypedImage | ( | const ImageDescriptor & | descriptor, |
| T * | data = nullptr, | ||
| Ownership | own = Ownership::NotOwning ) |
Create a new TypedImage from an ImageDescriptor.
| descriptor | ImageDescriptor of the new image, pixel type is ignored |
| data | Optional pointer to image data, must match the descriptor layout if not null. |
| own | Flag whether the newly created image shall take ownership of data. |
| TypedImage | ( | const vec3i & | dimensions, |
| int | numChannels = 1, | ||
| T * | data = nullptr, | ||
| Ownership | own = Ownership::NotOwning ) |
Create a new TypedImage with given dimensions and channels.
| dimensions | Image width, height, and slices |
| numChannels | Number of channels |
| data | Optional pointer to image data, must match the descriptor layout if not null. |
| own | Flag whether the newly created image shall take ownership of data. |
|
static |
Factory method to create a new TypedImage from an ImageDescriptor.
data buffer is not passed as argument, the data buffer of TypedImage is uninitialized | descriptor | ImageDescriptor of the new image, pixel type is ignored |
| data | Optional pointer to image data, must match the descriptor layout if not null. |
| own | Flag whether the newly created image shall take ownership of data. |
|
static |
Factory method to create a new TypedImage of given dimensions and number of channels.
data buffer is not passed as argument, the data buffer of TypedImage is uninitialized | dimensions | Image width, height, and slices |
| numChannels | Number of channels |
| data | Optional pointer to image data, must match the descriptor layout if not null. |
| own | Flag whether the newly created image shall take ownership of data. |
|
overridevirtual |
Update image data pointed to by this object.
If the other image is not compatible with the current one the image is resized. If the other image has a different type this method does nothing.
Implements MemImage.
| void fill | ( | const std::vector< T > & | channelValues | ) |
Fill image with the given channel values for all pixels.
The number of elements in channelValues must match the number of channels of this image.
|
overridevirtual |
Fill image with the given double value for all channels and pixels.
Implements MemImage.
|
overridevirtual |
Fill image with the given double channel values for all pixels.
Implements MemImage.
|
inlineoverridevirtual |
Returns a void pointer to the underlying raw pixel buffer of the image.
TypedImage<T> specialization provides pointer() as type-safe alternative. Implements MemImage.
|
inlineoverridevirtual |
Implements MemImage.
| T value | ( | int | x, |
| int | y, | ||
| int | z = 0, | ||
| int | c = 0 ) const |
Return the pixel intensity at the coordinate without interpolation.
|
inlineoverridevirtual |
Return the pixel intensity at the given index without interpolation casted to double.
Implements MemImage.
|
overridevirtual |
Return the pixel intensity at the coordinate without interpolation casted to double.
Implements MemImage.
|
overridevirtual |
Return the pixel intensity at the given coordinate using linear interpolation casted to double.
Implements MemImage.
| void setValue | ( | T | value, |
| int | x, | ||
| int | y, | ||
| int | z = 0, | ||
| int | c = 0 ) |
Set the pixel intensity at the given coordinate to value.
|
inlineoverridevirtual |
Set the pixel intensity at the given index to value casted to the underlying type without any clamping or normalization.
Implements MemImage.
|
overridevirtual |
Set the pixel intensity at the given coordinate to value casted to the underlying type without any clamping or normalization.
Implements MemImage.
|
overridevirtual |
Computes the minimum and maximum image intensity of the entire image casted to double.
Implements MemImage.
| std::unique_ptr< TypedImage< T > > 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.
|
overridevirtual |
Optimal rescaling and conversion to unsigned data type if applicable.
Implements MemImage.
|
overridevirtual |
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.
Implements MemImage.
|
overrideprotectedvirtual |
Implements MemImage.
|
overrideprotectedvirtual |
Implements MemImage.