ImageDescriptor
Struct describing the essential properties of an image.
The ImFusion framework distinguishes two main image pixel value domains, which are indicated by the shift and scale parameters of this image descriptor.
- Original pixel value domain: Pixel values are the same as in their original source (e.g. when loaded from a file). Same as the storage pixel value domain if the image's scale is 1 and the shift is 0
- Storage pixel value domain: Pixel values as they are stored in a MemImage. The user may decide to apply such a rescaling in order to better use the available limits of the underlying type.
The following conversion rules apply:
OV = (SV / scale) - shift
SV = (OV + shift) * scaleExtends
Properties
| Property | Type | Description |
|---|---|---|
pixelType | PixelType | The pixel/voxel data type |
width | number | Width of the image in pixels |
height | number | Height of the image in pixels |
slices | number | Depth of the image in pixels, or the number of 2D image slices |
channels | number | Number of channels per pixel/voxel |
isMetric | boolean | True if data is metric, you should not rely on any measuring tools if this is false |
shift | number | Optional intensity shift wrt. the original image values |
scale | number | Optional scaling wrt. the original image values, after shift |
spacing | vec3 | Physical pixel/voxel spacing in mm |
Methods
| Method | Description |
|---|---|
| size() | Returns the size (number of elements) of the image |
| dimension() | Returns the spatial dimension of the image, either 1, 2, or 3 |
| typeSize() | Return the nominal size in bytes of the current component type, zero if unknown |
| byteSize() | Returns the size of the image in bytes |
| isValid() | Return if the descriptor is valid (a size of one is allowed) |
| isApprox() | Convenience function to perform partial comparison of two image descriptors. |
| isPixelBufferCompatible() | Convenience function to check whether the pixel buffers of two descriptors are compatible. |
| storageToOriginal() | Applies the image's shift and scale in order to convert value from storage pixel value domain to original pixel value domain. |
| originalToStorage() | Applies the image's shift and scale in order to convert value from original pixel value domain to storage pixel value domain. |
| index() | Returns a linear memory index for a pixel or voxel |
| hasIndex() | Returns true if the pixel at (x,y,z) exists, false otherwise |
| setSpacing() | Convenience function for specifying spacing ImageDescriptor#spacing and metric ImageDescriptor#isMetric flag at the same time |
| extent() | Returns the physical size of the image in milimeters as a vector |
| setDimensions() | Convenience function for specifying the image dimensions and channels at once. |
| dimensions() | Returns the dimensions of the image in pixels as a vector |
| coord() | Returns the pixel/voxel coordinate (x,y,z,c) for a given index |
Inherited from ClassHandle
| Method | Description |
|---|---|
| isAliasOf() | Returns true if this handle and other alias the same underlying C++ object. |
| delete() | Releases this JavaScript handle. |
| deleteLater() | Schedules this handle for deferred deletion and returns this handle. |
| isDeleted() | Returns true if this handle has already been deleted. |
| [dispose]() | Releases this handle when the enclosing scope exits, so a handle can be declared with using instead of calling delete() later manually. |
| clone() | Returns a new JavaScript handle aliasing the same underlying C++ object. |
size()
size(): number;Returns the size (number of elements) of the image
Returns
number
dimension()
dimension(): number;Returns the spatial dimension of the image, either 1, 2, or 3
Returns
number
typeSize()
typeSize(): number;Return the nominal size in bytes of the current component type, zero if unknown
Returns
number
byteSize()
byteSize(): number;Returns the size of the image in bytes
Returns
number
isValid()
isValid(): boolean;Return if the descriptor is valid (a size of one is allowed)
Returns
boolean
isApprox()
isApprox(other: ImageDescriptor, partsToCompare?: ImageDescriptorComparison[]): boolean;Convenience function to perform partial comparison of two image descriptors.
In contrast to operator== this function will use approximate comparison of floating point members.
Parameters
| Parameter | Type | Description |
|---|---|---|
other | ImageDescriptor | - |
partsToCompare? | ImageDescriptorComparison[] | Optional array to select which aspects of the ImageDescriptor should be considered. |
Returns
boolean
isPixelBufferCompatible()
isPixelBufferCompatible(other: ImageDescriptor): boolean;Convenience function to check whether the pixel buffers of two descriptors are compatible.
This is the case if their type, dimensions, and number of channels are identical.
Has the same effect as isApprox(other, {ImageDescriptor::IgnoreSpacing, ImageDescriptor::IgnoreShiftScale}).
Parameters
| Parameter | Type |
|---|---|
other | ImageDescriptor |
Returns
boolean
storageToOriginal()
storageToOriginal(value: number): number;Applies the image's shift and scale in order to convert value from storage pixel value domain to original pixel value domain.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
number
originalToStorage()
originalToStorage(value: number): number;Applies the image's shift and scale in order to convert value from original pixel value domain to storage pixel value domain.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
number
index()
index(
x: number,
y: number,
z?: number,
c?: number): number;Returns a linear memory index for a pixel or voxel
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | x-coordinate |
y | number | y-coordinate |
z? | number | z-coordinate, defaults to 0 |
c? | number | channel, defaults to 0 |
Returns
number
hasIndex()
hasIndex(
x: number,
y: number,
z?: number,
c?: number): boolean;Returns true if the pixel at (x,y,z) exists, false otherwise
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | x-coordinate |
y | number | y-coordinate |
z? | number | z-coordinate, defaults to 0 |
c? | number | channel, defaults to 0 |
Returns
boolean
setSpacing()
setSpacing(spacing: vec3, isMetric: boolean): void;Convenience function for specifying spacing ImageDescriptor#spacing and metric ImageDescriptor#isMetric flag at the same time
Parameters
| Parameter | Type |
|---|---|
spacing | vec3 |
isMetric | boolean |
Returns
void
extent()
extent(): vec3;Returns the physical size of the image in milimeters as a vector
Returns
setDimensions()
setDimensions(dimensions: vec3i, channels?: number): void;Convenience function for specifying the image dimensions and channels at once.
Parameters
| Parameter | Type | Description |
|---|---|---|
dimensions | vec3i | The new dimensions for this image descriptor |
channels? | number | The new number of channels for this image descriptor. If omitted, the number of channels remains unchanged |
Returns
void
dimensions()
dimensions(): vec3i;Returns the dimensions of the image in pixels as a vector
Returns
coord()
coord(index: number): vec4i;Returns the pixel/voxel coordinate (x,y,z,c) for a given index
Parameters
| Parameter | Type | Description |
|---|---|---|
index | number | See ImageDescriptor#index |