Matlab DICOM Slices

2019-04-11 05:52发布

问题:

I have a DICOM image loaded as a matrix in matlab. My question is, how do I show specific slices of that image in each orthogonal direction?

Like view slice x at position 100, y=0, z=0

回答1:

If your matrix is M, and has d dimensions (3, or what have you) and you want to plot a 1-D "slice" of one of the dimensions then:

  plot(squeeze(M(n1,n2, ...,:,...));

where n1,n2,... are the positions of dimension x,y,... where you want to slice, and the operator (:) is the dimension you want to plot.

for example, given a 5 dimensional matrix M=rand(10,10,10,10,10), lets slice the 4-th dimension around some points (x=n1, y=n2, etc...)

   M=rand(10,10,10,10,10);
   n1=4; n2=7; n3=3; n5=5; 
   plot(squeeze(M(n1,n2, n3, :, n5)));

If the slice is 2-D then you can use imshow or imagesc to show the 2-D slice, for example showing the 2-nd and 4-th dimension:

 imagesc(squeeze(M(n1,:,n3,:,n5)))