Function convolveInto

Applies one compile-time fixed convolution kernel into caller-owned destination storage.

bool convolveInto(alias Kernel, Accumulator, T)(
  scope RasterView!T source,
  size_t sourcePlaneIndex,
  Region2D sourceOutputRegion,
  scope ref WritableRasterView!T destination,
  size_t destinationPlaneIndex,
  out RasterNeighbourhoodError error
) nothrow @nogc @safe
if (isSupportedConvolution!(T, Kernel.coefficientType, Accumulator));

Kernel is one FixedConvolutionKernel instantiation.

Accumulator is explicit.

Source/output T is limited to float/double in the initial production family.

Spatial semantics are exactly applyNeighbourhoodInto using Kernel.shape:

- sourceOutputRegion is resident-relative; - complete resident halo is required; - matching empty output succeeds; - destination shape must match output region; - destination must be injective; - exact required-source/destination overlap is rejected before writes; - every validated signed-affine layout remains supported; - no hidden allocation or scheduling occurs.

Border semantics are currently the valid/resident-halo policy of applyNeighbourhoodInto. The generic border policy model is separate and does not silently synthesize edge samples here.

Returns the same RasterNeighbourhoodError structural failure model used by the underlying spatial primitive.

Example

Example using a fixed centered 3 x 3 identity convolution.

import raster;

alias Shape =
    NeighbourhoodShape!(
        3,
        3,
        1,
        1
    );

alias Kernel =
    FixedConvolutionKernel!(
        Shape,
        float,
        0.0f, 0.0f, 0.0f,
        0.0f, 1.0f, 0.0f,
        0.0f, 0.0f, 0.0f
    );

RasterView!float source;
WritableRasterView!float destination;

RasterNeighbourhoodError error;

assert(
    !source.convolveInto!(
        Kernel,
        float
    )(
        0,
        Region2D(1, 1, 1, 1),
        destination,
        0,
        error
    )
);

assert(
    error
    == RasterNeighbourhoodError.invalidSourcePlane
);