Function tryApplyRasterNeighbourhood3x3

Applies one compile-time same-type kernel to every 3 x 3 neighbourhood centered on sourceOutputRegion.

bool tryApplyRasterNeighbourhood3x3(alias kernel, T)(
  scope RasterView!T source,
  size_t sourcePlaneIndex,
  Region2D sourceOutputRegion,
  scope ref WritableRasterView!T destination,
  size_t destinationPlaneIndex,
  out RasterNeighbourhood3x3Error error
) nothrow @nogc @safe;

sourceOutputRegion is relative to the supplied source view.

For non-empty output, one resident source sample must exist on all four sides of sourceOutputRegion. Destination width and height must equal the output-region width and height.

The operation defines no border policy and does not inspect logical/global dependency metadata or ContextDeficit.

The kernel receives nine source values in row-major order. Index 4 is the center sample. The kernel must be usable as a safe, pure, nothrow, nogc same-type callable.

Structural failures occur before the first destination write. Destination mapping must be injective, and the exact required source sample bytes must be physically disjoint from destination sample bytes.

Matching empty output succeeds without requiring halo or invoking kernel.

Example

Example reporting an invalid source plane for a 3 x 3 kernel.

import raster;
alias center = (ref const(float)[9] values) @safe pure nothrow @nogc => values[4];
RasterView!float source;
WritableRasterView!float destination;
RasterNeighbourhood3x3Error error;
assert(!tryApplyRasterNeighbourhood3x3!center(
    source, 0, Region2D(0, 0, 1, 1), destination, 0, error));
assert(error == RasterNeighbourhood3x3Error.invalidSourcePlane);