ImFusion Web SDK

SharedImageSet

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.

Extends

Accessors

Inherited from Data

AccessorDescription
nameThe name of the dataset

Methods

MethodDescription
autoWindow()Perform an automatic windowing of the dataset so that the entire intensity range is visible.
focus()Returns the index of the focused image in the image set.
setFocus()Sets the focus to the image at the given index.
size()Returns the number of images in the image set.
add()Add an image to the image set.
remove()Remove an image from the image set at the specified index.
imageInfo()Returns the ImageInfo of this SharedImageSet if present.
setModality()Set image modality for all frames
isMultiModal()Return true if set contains images of different modalities, false otherwise
clear()Clear all data and delete it if owned
hasTransformations()Return true if at least one image in the set has a matrix transformation unequal identity.
hasTimestamps()Return if all image frames have timestamps
allEqual()Return if all image descriptors are the same
get()Get a specific image from the image set as a ref-counted handle.
descriptor()Returns the descriptor for the given imageIndex, or the currently focused image if imageIndex is omitted.
setTimestamp()Set specific or focused timestamp in seconds.
timestamp()Get specific or focused timestamp in seconds.
displayOptions2d()Returns the handle to the 2d display options used by slice renderers to render this dataset.
displayOptions3d()Returns the handle to the 3d display options used by volume renderers to render this dataset.
onSelectionChanged()Fires when the selection (focus) of the image set changes.
histogram()Computes the intensity histogram of this image over the entire [range of available image pixels]SharedImageSetHandle#minmaxIntensityOriginal.
timestamps()Get the timestamps sequence
thumbnail()Creates a thumbnail for the image at the given index.
minmaxIntensityOriginal()Returns the intensity range of this image in original value domain.
matrixFromWorld()Get image matrix mapping from the world coordinate system.
matrixToWorld()Get image matrix mapping from the world coordinate system.
setMatrixFromWorld()Set image matrix mapping from the world coordinate system.
setMatrixToWorld()Set image matrix mapping from the world coordinate system.

Inherited from Data

MethodDescription
kind()Returns the kind of this data.
modality()Returns the modality of this data.
bounds()Returns the axis-aligned bounding box of this data in world space.

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.

autoWindow()

ts
autoWindow(): void;

Perform an automatic windowing of the dataset so that the entire intensity range is visible.

Returns

void


focus()

ts
focus(): number;

Returns the index of the focused image in the image set.

Returns

number


setFocus()

ts
setFocus(focus: number): void;

Sets the focus to the image at the given index.

Parameters

ParameterType
focusnumber

Returns

void

true if the focus was set successfully, false otherwise.


size()

ts
size(): number;

Returns the number of images in the image set.

Returns

number


add()

ts
add(img: Image | null): void;

Add an image to the image set.

Parameters

ParameterTypeDescription
imgImage | nullRef-counted handle to the image to add to the set.

Returns

void


remove()

ts
remove(index: number): void;

Remove an image from the image set at the specified index.

Parameters

ParameterTypeDescription
indexnumberIndex of the image to remove.

Returns

void


imageInfo()

ts
imageInfo(): ImageInfo | null;

Returns the ImageInfo of this SharedImageSet if present.

Returns

ImageInfo | null


setModality()

ts
setModality(modality: DataModality): void;

Set image modality for all frames

Parameters

ParameterType
modalityDataModality

Returns

void


isMultiModal()

ts
isMultiModal(): boolean;

Return true if set contains images of different modalities, false otherwise

Returns

boolean


clear()

ts
clear(): void;

Clear all data and delete it if owned

Returns

void


hasTransformations()

ts
hasTransformations(): boolean;

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

Returns

boolean


hasTimestamps()

ts
hasTimestamps(): boolean;

Return if all image frames have timestamps

Returns

boolean


allEqual()

ts
allEqual(): boolean;

Return if all image descriptors are the same

Returns

boolean


get()

ts
get(index?: number): Image | null;

Get a specific image from the image set as a ref-counted handle.

While the garbage collector will eventually decrement the reference count, it is recommended to manually call delete() on the returned handle once it is no longer needed on the JS side.

Parameters

ParameterTypeDescription
index?numberIndex of the image to get. If not provided, the focused image is returned.

Returns

Image | null

image at index index if it exists, otherwise null.

Example

ts
const image = imageSet.get(0);
otherImageSet.add(image); // otherImageSet now has shared ownership of the image
image.delete(); // image is now invalid on the JS side, but remains valid inside otherImageSet.

descriptor()

ts
descriptor(imageIndex?: number): ImageDescriptor;

Returns the descriptor for the given imageIndex, or the currently focused image if imageIndex is omitted.

Parameters

ParameterTypeDescription
imageIndex?numberDefaults to the currently focused image if omitted.

Returns

ImageDescriptor

Once the handle to the returned object is no longer needed on the JS side, it must be released by calling delete(). Prefer declaring the variable with using so this happens automatically:

ts
using descriptor = imageSet.descriptor();

setTimestamp()

ts
setTimestamp(timeInSeconds: number, imageIndex?: number): void;

Set specific or focused timestamp in seconds.

Parameters

ParameterTypeDescription
timeInSecondsnumber-
imageIndex?numberDefaults to the currently focused image if omitted

Returns

void


timestamp()

ts
timestamp(imageIndex?: number): number;

Get specific or focused timestamp in seconds.

Parameters

ParameterTypeDescription
imageIndex?numberDefaults to the currently focused image if omitted

Returns

number


displayOptions2d()

ts
displayOptions2d(): DisplayOptions2d;

Returns the handle to the 2d display options used by slice renderers to render this dataset.

Returns

DisplayOptions2d


displayOptions3d()

ts
displayOptions3d(): DisplayOptions3d;

Returns the handle to the 3d display options used by volume renderers to render this dataset.

Returns

DisplayOptions3d


onSelectionChanged()

ts
onSelectionChanged(callback: () => void): () => void;

Fires when the selection (focus) of the image set changes.

Parameters

ParameterType
callback() => void

Returns

Unsubscribe function.

() => void


histogram()

ts
histogram(numBins: number): number[];

Computes the intensity histogram of this image over the entire [range of available image pixels]SharedImageSetHandle#minmaxIntensityOriginal.

Parameters

ParameterTypeDescription
numBinsnumberNumber of bins the returned histogram should have.

Returns

number[]

array of numBins numbers, each number corresponds to the number of image pixels that have an intensity corresponding to that bin.


timestamps()

ts
timestamps(): number[];

Get the timestamps sequence

Returns

number[]


thumbnail()

ts
thumbnail(
   index: number,
   width: number,
   height: number): Uint8Array;

Creates a thumbnail for the image at the given index.

Parameters

ParameterTypeDescription
indexnumberIndex of the image to create a thumbnail for.
widthnumberWidth of the thumbnail in pixels.
heightnumberHeight of the thumbnail in pixels.

Returns

Uint8Array

A JS-owned Uint8Array containing the PNG-encoded thumbnail image.

Example

ts
const bytes = sis.thumbnail(0, 32, 32);
const url = URL.createObjectURL(new Blob([bytes], { type: 'image/png' }));
img.src = url; // display the image

minmaxIntensityOriginal()

ts
minmaxIntensityOriginal(): vec2;

Returns the intensity range of this image in original value domain.

Returns

vec2

array of 2 numbers: minimum and maximum intensity


matrixFromWorld()

ts
matrixFromWorld(imageIndex?: number): mat4;

Get image matrix mapping from the world coordinate system.

Parameters

ParameterTypeDescription
imageIndex?numberThe index of the image in the SharedImageset, if omitted, the currently focused image will be used.

Returns

mat4


matrixToWorld()

ts
matrixToWorld(imageIndex?: number): mat4;

Get image matrix mapping from the world coordinate system.

Parameters

ParameterTypeDescription
imageIndex?numberThe index of the image in the SharedImageset, if omitted, the currently focused image will be used.

Returns

mat4


setMatrixFromWorld()

ts
setMatrixFromWorld(
   m: mat4,
   imageIndex?: number,
   updateAll?: boolean): void;

Set image matrix mapping from the world coordinate system.

Parameters

ParameterTypeDescription
mmat4-
imageIndex?numberThe index of the image in the SharedImageset, if omitted, the currently focused image will be used. The currently focused image will also be used if the given imageIndex is out of bounds.
updateAll?booleanIf set, the matrices of all images are updated relative to the given imageIndex. Defaults to false

Returns

void


setMatrixToWorld()

ts
setMatrixToWorld(
   m: mat4,
   imageIndex?: number,
   updateAll?: boolean): void;

Set image matrix mapping from the world coordinate system.

Parameters

ParameterTypeDescription
mmat4-
imageIndex?numberThe index of the image in the SharedImageset, if omitted, the currently focused image will be used. The currently focused image will also be used if the given imageIndex is out of bounds.
updateAll?booleanIf set, the matrices of all images are updated relative to the given imageIndex. Defaults to false

Returns

void

On this page