Skip to content

Class: ImageSlice ​

Defined in: src/display/ImageSlice.ts:32

Represents a single 2D slice of image data along with spatial metadata.

Constructors ​

Constructor ​

ts
new ImageSlice(
   imageData, 
   boundingBox, 
   spacing, 
   axes, 
   upsample?): ImageSlice;

Defined in: src/display/ImageSlice.ts:51

Constructs an ImageSlice instance.

Parameters ​

imageData ​

ImageData

A browser ImageData object containing pixel data (RGBA).

boundingBox ​

BoundingBox

The real-world bounding box (xMin, xMax, yMin, yMax).

spacing ​

number[]

The slice's pixel spacing along X and Y in real units (e.g., mm per pixel).

axes ​

AxisSet2D

A 2D axis set specifying how the slice is oriented (e.g., LEFT_RIGHT x POST_ANT).

upsample? ​

number = 1

Returns ​

ImageSlice

Properties ​

upsample ​

ts
readonly upsample: number;

Defined in: src/display/ImageSlice.ts:42

Pixels per source voxel along each in-plane axis. Greater than 1 when the slice was resampled for display ('smooth'/'cubic'); renderers divide the sprite scale by it so content space stays in voxel units.

Accessors ​

width ​

Get Signature ​

ts
get width(): number;

Defined in: src/display/ImageSlice.ts:70

Returns the pixel width of the slice.

Example ​
ts
const sliceWidth = mySlice.width;
Returns ​

number


height ​

Get Signature ​

ts
get height(): number;

Defined in: src/display/ImageSlice.ts:79

Returns the pixel height of the slice.

Example ​
ts
const sliceHeight = mySlice.height;
Returns ​

number


data ​

Get Signature ​

ts
get data(): ImageData;

Defined in: src/display/ImageSlice.ts:87

The raw browser ImageData (width, height, RGBA pixel array). This is typically fed directly into a texture for rendering.

Returns ​

ImageData


getSpacing ​

Get Signature ​

ts
get getSpacing(): number[];

Defined in: src/display/ImageSlice.ts:97

Returns the pixel spacing for X and Y axes. Usually measured in real units (e.g., mm/pixel).

Example ​
ts
const [sx, sy] = mySlice.getSpacing; // 2.0, 2.0
Returns ​

number[]


getOrigin ​

Get Signature ​

ts
get getOrigin(): [number, number];

Defined in: src/display/ImageSlice.ts:107

Returns the real-world origin of the slice in the X-Y plane, typically corresponding to the bounding box’s (xMin, yMin).

Example ​
ts
const [ox, oy] = mySlice.getOrigin; // e.g., [-90, -126]
Returns ​

[number, number]


bounds ​

Get Signature ​

ts
get bounds(): [number, number][];

Defined in: src/display/ImageSlice.ts:118

The corner coordinates of this slice in real-world space (X-Y). Points are returned in the order: bottom-left, bottom-right, top-left, top-right.

Example ​
ts
const corners = mySlice.bounds; // [[xMin,yMin],[xMax,yMin],...]
Returns ​

[number, number][]

Methods ​

prettyPrint() ​

ts
prettyPrint(): string;

Defined in: src/display/ImageSlice.ts:138

Returns a string representation of the slice for debugging purposes. Includes dimensions, spacing, origin, and bounding box information.

Returns ​

string

A formatted string with slice details.

Example ​

ts
console.log(mySlice.prettyPrint());
  // ImageSlice: 256×256 pixels
  // Spacing: [1.0, 1.0] mm/pixel
  // Origin: [-128.0, -128.0]
  // Bounds: [[-128,-128], [128,-128], [-128,128], [128,128]]

Released under the MIT License.