2

I have a 3D matrix in Matlab which corresponds to an energy dose delivered matrix. I am trying to visualize and represent the matrix. At the moment I am doing the following (thanks to another post).

diff = double(squeeze(diff));
h = slice(diff, [], [], 1:size(diff,3));
set(h, 'EdgeColor','none', 'FaceColor','interp')
alpha(.1)

enter image description here That gives me a good 3D plot, however it is still difficult to see it properly and I have to keep rotating the figure to be able to visualize it properly. I have also used :

isosurface(diff,'isovalue')

but again it is hard to see anything.

I was wondering if there is a way of getting rid of the blue area around the actual dose representation since the blue area corresponds to 0 values. Perhaps getting rid of that could help me to see a much more clear picture.

Community
  • 1
  • 1
Manolete
  • 3,431
  • 7
  • 54
  • 92

2 Answers2

8

you can set the zeros to nan so that they are not plotted

diff = double(squeeze(diff));
diff(diff==0)=nan;                              % added line
h = slice(diff, [], [], 1:size(diff,3));
set(h, 'EdgeColor','none', 'FaceColor','interp')
alpha(.1)

Example

using the MRI data form the previous question

load mri
D = double(squeeze(D));
D(D==0)=nan;
h = slice(D, [], [], 1:size(D,3));
set(h, 'EdgeColor','none', 'FaceColor','interp')
alpha(.1)

output

with replacing zeros with nan enter image description here
without replacing zeros with nan enter image description here

RTL
  • 3,577
  • 15
  • 24
6

One way to do this is to make a copy of the data with the values you don't want represented by NaN. For example, here is the original example image from the other post

enter image description here

Now if we take the same set of image data, replace zeros with NaN and plot using the same method:

D(D==0)=NaN;
h = slice(D, [], [], 1:size(D,3));
set(h, 'EdgeColor','none', 'FaceColor','interp')
alpha(.1)

enter image description here

Community
  • 1
  • 1
nkjt
  • 7,825
  • 9
  • 22
  • 28