ImFusion Web SDK

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:

plaintext
  OV = (SV / scale) - shift
  SV = (OV + shift) * scale

Extends

Properties

PropertyTypeDescription
pixelTypePixelTypeThe pixel/voxel data type
widthnumberWidth of the image in pixels
heightnumberHeight of the image in pixels
slicesnumberDepth of the image in pixels, or the number of 2D image slices
channelsnumberNumber of channels per pixel/voxel
isMetricbooleanTrue if data is metric, you should not rely on any measuring tools if this is false
shiftnumberOptional intensity shift wrt. the original image values
scalenumberOptional scaling wrt. the original image values, after shift
spacingvec3Physical pixel/voxel spacing in mm

Methods

MethodDescription
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

MethodDescription
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()

ts
size(): number;

Returns the size (number of elements) of the image

Returns

number


dimension()

ts
dimension(): number;

Returns the spatial dimension of the image, either 1, 2, or 3

Returns

number


typeSize()

ts
typeSize(): number;

Return the nominal size in bytes of the current component type, zero if unknown

Returns

number


byteSize()

ts
byteSize(): number;

Returns the size of the image in bytes

Returns

number


isValid()

ts
isValid(): boolean;

Return if the descriptor is valid (a size of one is allowed)

Returns

boolean


isApprox()

ts
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

ParameterTypeDescription
otherImageDescriptor-
partsToCompare?ImageDescriptorComparison[]Optional array to select which aspects of the ImageDescriptor should be considered.

Returns

boolean


isPixelBufferCompatible()

ts
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

ParameterType
otherImageDescriptor

Returns

boolean


storageToOriginal()

ts
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

ParameterType
valuenumber

Returns

number


originalToStorage()

ts
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

ParameterType
valuenumber

Returns

number


index()

ts
index(
   x: number,
   y: number,
   z?: number,
   c?: number): number;

Returns a linear memory index for a pixel or voxel

Parameters

ParameterTypeDescription
xnumberx-coordinate
ynumbery-coordinate
z?numberz-coordinate, defaults to 0
c?numberchannel, defaults to 0

Returns

number


hasIndex()

ts
hasIndex(
   x: number,
   y: number,
   z?: number,
   c?: number): boolean;

Returns true if the pixel at (x,y,z) exists, false otherwise

Parameters

ParameterTypeDescription
xnumberx-coordinate
ynumbery-coordinate
z?numberz-coordinate, defaults to 0
c?numberchannel, defaults to 0

Returns

boolean


setSpacing()

ts
setSpacing(spacing: vec3, isMetric: boolean): void;

Convenience function for specifying spacing ImageDescriptor#spacing and metric ImageDescriptor#isMetric flag at the same time

Parameters

ParameterType
spacingvec3
isMetricboolean

Returns

void


extent()

ts
extent(): vec3;

Returns the physical size of the image in milimeters as a vector

Returns

vec3


setDimensions()

ts
setDimensions(dimensions: vec3i, channels?: number): void;

Convenience function for specifying the image dimensions and channels at once.

Parameters

ParameterTypeDescription
dimensionsvec3iThe new dimensions for this image descriptor
channels?numberThe new number of channels for this image descriptor. If omitted, the number of channels remains unchanged

Returns

void


dimensions()

ts
dimensions(): vec3i;

Returns the dimensions of the image in pixels as a vector

Returns

vec3i


coord()

ts
coord(index: number): vec4i;

Returns the pixel/voxel coordinate (x,y,z,c) for a given index

Parameters

ParameterTypeDescription
indexnumberSee ImageDescriptor#index

Returns

vec4i

On this page