DWVv0.37.0

ImageContour

Source: imageContour.js:18

Image contour buffer manager. Caches per-pixel distance-to-border values for contour rendering. Stores 3 distance values per pixel (one per orientation: x, y, z).


Constructor

new ImageContour(): ImageContour

Instance Methods

initialize(imageBuffer: Uint8Array, imageSize: Size)

Initialize the contour buffer. Should be called on every segmentation image, or any image where contour rendering needs to be supported.

Parameters

  • imageBuffer (Uint8Array) — The image data buffer.
  • imageSize (Size) — The image size.

isInitialized(): boolean

Get whether or not the contour buffer has been initialized.

Returns

  • boolean — True if buffer has been initialized.

realloc(imageBuffer: Uint8Array, imageSize: Size)

Re-allocate contour buffer memory after an image buffer resize. Updates the stored image buffer and size references.

Parameters

  • imageBuffer (Uint8Array) — The new image data buffer.
  • imageSize (Size) — The new image size.

shiftSlice( contourIndexOffset: number, contourSliceSize: number, contourMaxOffset: number, )

Shift contour buffer content to make room for an inserted slice.

Parameters

  • contourIndexOffset (number) — Start offset of the slice to shift.
  • contourSliceSize (number) — Size of one contour slice.
  • contourMaxOffset (number) — End offset of content to shift.

resetAroundOffset(offset: number)

Reset contour buffer for the values around an offset. Prevents certain artifacts, especially at small brush sizes and when erasing.

Parameters

  • offset (number) — The offset to reset.

getDistance(index: number, viewOrientation: Matrix33): number

Calculate the distance to the nearest border pixel (or return the cached distance). Returns 0 if the contour buffer is not initialized.

Parameters

  • index (number) — Index/offset of the pixel to check.
  • viewOrientation (Matrix33) — The orientation of the view.

Returns

  • number — The distance to the nearest border pixel or 0.