Struct NeighbourhoodShape
Fixed neighbourhood geometry with one explicit anchor.
struct NeighbourhoodShape(ulong Width, ulong Height, ulong AnchorX, ulong AnchorY);
Width and Height must be non-zero.
AnchorX and AnchorY identify the output sample position inside the
neighbourhood
0 <= AnchorX < Width 0 <= AnchorY < Height
The derived margins are:
left = AnchorX right = Width - AnchorX - 1 top = AnchorY bottom = Height - AnchorY - 1
sampleCount is Width * Height and must fit size_t.
This type intentionally stores no runtime fields. The geometry exists only as compile-time enum members and is intended to be passed as a template argument to fixed-shape spatial operations.
No default anchor is inferred. Even-sized and asymmetric neighbourhoods are therefore never assigned a hidden center.
Example
Example defining the existing centered 3 x 3 geometry structurally.
import raster;
alias Shape =
NeighbourhoodShape!(
3,
3,
1,
1
);
static assert(Shape .width == 3);
static assert(Shape .height == 3);
static assert(Shape .anchorX == 1);
static assert(Shape .anchorY == 1);
static assert(Shape .left == 1);
static assert(Shape .right == 1);
static assert(Shape .top == 1);
static assert(Shape .bottom == 1);
static assert(Shape .sampleCount == 9);