vibespatial.raster.distance

Euclidean Distance Transform via Jump Flooding Algorithm.

CPU baseline uses scipy.ndimage.distance_transform_edt. GPU path uses custom NVRTC kernels implementing the Jump Flooding Algorithm (JFA) for O(log N) parallel distance computation.

The EDT computes, for each background (zero/False) pixel, the Euclidean distance to the nearest foreground (nonzero/True) pixel. Foreground pixels have distance 0. Nodata pixels propagate as nodata in the output.

Attributes

Functions

raster_distance_transform(...)

Compute Euclidean Distance Transform of a raster.

Module Contents

vibespatial.raster.distance.raster_distance_transform(raster: vibespatial.raster.buffers.OwnedRasterArray, *, use_gpu: bool | None = None) vibespatial.raster.buffers.OwnedRasterArray

Compute Euclidean Distance Transform of a raster.

For each background (zero/False) pixel, computes the Euclidean distance (in pixel units) to the nearest foreground (nonzero/True) pixel. Foreground pixels have distance 0. Nodata pixels propagate as NaN.

Multiband rasters are supported: each band is processed independently and the result has the same band count as the input.

Parameters

rasterOwnedRasterArray

Input raster (single- or multi-band). Nonzero (and non-nodata) values are foreground.

use_gpubool or None

Force GPU (True), force CPU (False), or auto-dispatch (None). Auto uses GPU when CuPy is available and pixel count exceeds the internal threshold.

Returns

OwnedRasterArray

Float64 raster of Euclidean distances. Foreground pixels = 0.0, nodata pixels = NaN (if input has nodata). For multiband input, the output shape is (bands, H, W).

vibespatial.raster.distance.logger