質問

I have a 3d matrix of numbers (16x16x5). One layer is depicted by following matrix:

m = matrix (sample(0:127,256,replace=TRUE), nrow=16)

Similar 5 matrices are there in the stack.

  1. How can I depict them as R objects? Following code does not work:

    m = list(list(128),list(128), list(128), list(128), list(128))
    for(i in 1:5) m[i] = matrix (sample(0:127,256,replace=TRUE), nrow=10)
    
  2. How can I plot them so that each matrix is plotted as a contour-plot with semitransparent color (only one shade needed, eg gray) and 5 matrices are plotted on top of each other. It should be preferably possible to move the plot with mouse (as with plot3d or rgl.surface of rgl).

The question is similar to that of volume rendering as on this page: http://www.mathworks.in/help/matlab/ref/smooth3.html or on this page: How can I visualize volume data as shown here, in MATLAB?

Edit: following works to produce the 3d matrix:

array(sample(0:127,256*5,replace=TRUE), c(16,16,5))
役に立ちましたか?

解決

enter image description here

require(rgl)

plot3d(rep(1:128, 128*5),
   rep(1:128,each=128*5), 
   rep(1:5, 128*128), 
   col=colorRampPalette(c(rgb(1,0,0,.1), rgb(0,0,1,.1)), alpha=TRUE)(128)[ m ])
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top