Do any #rstats gurus happen to know about a package function that does the 2D equivalent of run length encoding?
The idea is for a matrix like the following...
> m <- matrix(c(1,1,2,1,1,2,2,2,1), 3, 3)
> m
[,1] [,2] [,3]
[1,] 1 1 2
[2,] 1 1 2
[3,] 2 2 1
...find (the positions of) rectangles with the same value. For example the first 'run' is m[1:2, 1:2] in this case, the second m[1:2, 3], third m[3, 1:2] and last m[3, 3].