1

I have a 3D brain volume (x, y) coordinates and z=slices. For this volume, I have specific coordinates (that reflects some features) and I want to highlight these coordinates (e.g. through drawing with specific color). I searched and found a code like that:

t=image;                 % gray scale image
red=t;
green=t;
blue=t;
for i=1:size(indx,1)     %indx: indexes of the featured coordinates
red(indx(i,1),indx(i,2))=255;
green(indx(i,1),indx(i,2))=0;
blue(indx(i,1),indx(i,2))=0;
end
out=cat(3,red,green,blue);

The problem is that, this code works with gray scale image. When I tried to generalize it to the volume I got something with the size:(x,y,z,3) through:

for i=1:size(indx,1)
red(indx(i,1),indx(i,2),indx(i,3))=255;
green(indx(i,1),indx(i,2),indx(i,3))=0;
blue(indx(i,1),indx(i,2),indx(i,3))=0;
end
out = cat(4, red, green, blue);

Is this generalization right? if so, how to show the resulting slices with the colored parts?

1 Answers1

0

You can do that but the datasets triple in size and you really don't gain anything. Instead I would create a label volume, such as:

VolLabels = uint8(VolData);

VolLabels(indx) = 1; %same notation, linear indices. 'colour1'
VolLabels(indx2) = 2; %different feature, 'colour2'

Then you can view the slices normally, i.e. imshow(VolLabels(:,:,sliceZ)). Then by using the imcontrast tool you can set the feature(s) you want to see, by setting the limits. Playing around with the colourmaps helps too.

Or extract volumes with only one feature by:

VolRedLabel = VolLabels == 1; %extracts the 'colour1' label

If you are just starting with Matlab and CT (MRI?)-images check out the function isosurface(). It stops working with larger datasets though.

Tapio
  • 1,502
  • 1
  • 12
  • 24