Flood fill does not work on 3D arrays. I suggest to either implement it so that it works on ND Arrays or to throw an error.
> x <- array(0, c(4, 4, 4))
+ x[1:2, 1:2, 1:2] <- 1
+ x <- floodFill(x, c(2, 2, 2), 2)
+
Warning messages:
1: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
data length [3] is not a sub-multiple or multiple of the number of columns [2]
2: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
data length [3] is not a sub-multiple or multiple of the number of columns [2]
3: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
data length [3] is not a sub-multiple or multiple of the number of columns [2]
4: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
data length [3] is not a sub-multiple or multiple of the number of columns [2]
> x
, , 1
[,1] [,2] [,3] [,4]
[1,] 2 2 0 0
[2,] 2 2 0 0
[3,] 0 0 0 0
[4,] 0 0 0 0
, , 2
[,1] [,2] [,3] [,4]
[1,] 2 2 0 0
[2,] 2 2 0 0
[3,] 0 0 0 0
[4,] 0 0 0 0
, , 3
[,1] [,2] [,3] [,4]
[1,] 2 2 2 2
[2,] 2 2 2 2
[3,] 2 2 2 2
[4,] 2 2 2 2
, , 4
[,1] [,2] [,3] [,4]
[1,] 2 2 2 2
[2,] 2 2 2 2
[3,] 2 2 2 2
[4,] 2 2 2 2