Class: ImageSlice
Defined in: src/display/ImageSlice.ts:32
Represents a single 2D slice of image data along with spatial metadata.
Constructors
Constructor
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
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
A 2D axis set specifying how the slice is oriented (e.g., LEFT_RIGHT x POST_ANT).
upsample?
number = 1
Returns
ImageSlice
Properties
upsample
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
get width(): number;Defined in: src/display/ImageSlice.ts:70
Returns the pixel width of the slice.
Example
const sliceWidth = mySlice.width;Returns
number
height
Get Signature
get height(): number;Defined in: src/display/ImageSlice.ts:79
Returns the pixel height of the slice.
Example
const sliceHeight = mySlice.height;Returns
number
data
Get Signature
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
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
const [sx, sy] = mySlice.getSpacing; // 2.0, 2.0Returns
number[]
getOrigin
Get Signature
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
const [ox, oy] = mySlice.getOrigin; // e.g., [-90, -126]Returns
[number, number]
bounds
Get Signature
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
const corners = mySlice.bounds; // [[xMin,yMin],[xMax,yMin],...]Returns
[number, number][]
Methods
prettyPrint()
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
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]]