nat
nat copied to clipboard
im3d should set dim on input data when possible
im3d(1:12, dims=c(2,3,4))
should give an array with real dimensions c(2,3,4).
I think at some point should be doing:
if(length(x)>0) dim(x)=dims
although not sure if re-setting dims on large x
is wasteful.
Hmm, this is quite a tricky issue, because the dimension information is actually processed by im3d quite a bit, even when it has been passed explicitly by setting im3d(x, dims=)
. I have experimented with
- always setting it
- setting it if not already set
- setting it to exactly what was passed in as dims.
and none pass the present test suite. The place where things fall over is for imslice
and projection
when they result in a single 2d slice whereas the formal definition of im3d
says that everything must be 3d and an extra singleton dimension is added if necessary.
Does this mean we should be thinking about adding e.g.
-
imnd
base class -
im2d
class
or perhaps switching to an e.g. im5d
class, which is completely general?