public static Image <TPixelType> ForBlockNeighbourhood <TPixelType>(this Image <TPixelType> image, int x, int y, int width, int height, int range, ForNeighbourhoodHandler <TPixelType> action) { ValidateForBlockNeighbourhood(image, x, y, width, height); int widthEnd = x + width; int heightEnd = y + height; for (int i = y; i < heightEnd; i++) { for (int j = x; j < widthEnd; j++) { var neighbourhood = image.GetNeighbourhood(j, i, range); action(j, i, neighbourhood); } } return(image); }
public static Image <TPixelType> ForEachNeighbourhood <TPixelType>(this Image <TPixelType> image, int range, ForNeighbourhoodHandler <TPixelType> action) { return(image.ForBlockNeighbourhood(0, 0, image.Width, image.Height, range, action)); }