Function applyNeighbourhoodInto
Applies one compile-time fixed neighbourhood shape and kernel into a caller-owned destination.
bool applyNeighbourhoodInto(alias Shape, alias kernel, T)(
scope RasterView!T source,
size_t sourcePlaneIndex,
Region2D sourceOutputRegion,
scope ref WritableRasterView!T destination,
size_t destinationPlaneIndex,
out RasterNeighbourhoodError error
) nothrow @nogc @safe;
Shape is expected to be one NeighbourhoodShape instantiation.
sourceOutputRegion is resident-relative to source.
For non-empty output, source must contain the complete neighbourhood margins derived from Shape:
left = Shape.left right = Shape.right top = Shape.top bottom = Shape.bottom
Destination width/height must equal sourceOutputRegion width/height.
Kernel receives Shape.sampleCount values in row-major neighbourhood order. Shape.anchorX/anchorY identify the output sample position inside that order.
Matching empty output succeeds without requiring halo and without invoking kernel.
Structural failures occur before the first destination write.
Every validated resident signed-affine layout remains supported.
No border policy is implied. Missing halo is RasterNeighbourhoodError.unsatisfiedNeighbourhood.
No allocation, retained ownership or scheduling occurs.
Example
Example reporting an invalid source plane through the generic family.
import raster;
alias Shape =
NeighbourhoodShape!(
5,
3,
2,
1
);
alias center =
(ref const(float)[15] values)
@safe pure nothrow @nogc
=> values[7];
RasterView!float source;
WritableRasterView!float destination;
RasterNeighbourhoodError error;
assert(
!source .applyNeighbourhoodInto!(
Shape,
center
)(
0,
Region2D(0, 0, 1, 1),
destination,
0,
error
)
);
assert(
error
== RasterNeighbourhoodError .invalidSourcePlane
);