aoles / EBImage

:art: Image processing toolbox for R
71 stars 28 forks source link

floodFill does not work for ND Arrays #57

Open gdkrmr opened 3 years ago

gdkrmr commented 3 years ago

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
aoles commented 1 year ago

Thanks for your feedback! Did you by any chance start working on a solution addressing the issue? If this is the case please feel free to submit a PR. Cheers!

gdkrmr commented 1 year ago

No solution from my side, this was from a project of a student.