DistanceField

class DistanceField : Filter1to1(source)

The DistanceField class provides an implementation for computing a distance field representation of an image. The distance field calculation is achieved via mechanisms like thresholding, contour tracing, and jump flooding. This class can operate on a single source image and produce a single target image.

The distance field process involves:

  • Applying a threshold filter to the source image to create a binary image representation.

  • Computing the contours of the binary representation.

  • Using a jump flooding algorithm to compute distances from each pixel to the nearest contour point.

  • Optionally utilizing signed distances by distinguishing between pixels inside and outside the contour.

The class uses several configurable parameters and intermediate processing steps:

  • threshold: Controls the binary threshold level used in the threshold filter.

  • distanceScale: Scales the computed distance field values.

  • signedDistance: Indicates whether the distance field should contain signed or unsigned distances.

Internal optimizations include resizing the input to power-of-two dimensions for efficient processing, and reusing intermediate buffers to reduce memory allocation overhead.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var depthBufferOut: DepthBuffer?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun apply(source: Array<ColorBuffer>, target: ColorBuffer, clip: Rectangle?)
fun apply(source: Array<ColorBuffer>, target: RenderTarget, clip: Rectangle?)
fun apply(source: ColorBuffer, target: Array<ColorBuffer>, clip: Rectangle?)
fun apply(source: ColorBuffer, target: ColorBuffer, clip: Rectangle?)
open override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?)
Link copied to clipboard
open override fun close()
Link copied to clipboard
open fun destroy()
Link copied to clipboard
fun untrack()