Posts: 14,118
Threads: 61
Joined: Oct 2014
The first example is an insect brain. This work was done by Nichole VanderSal in Cornell. The inputs are TIFF files. The first Matlab program to read the files continues. TIFF files must be numbered sequentially. After running this program, the "Slice" array is manually stored as a Matmat * .mat file.
Programs
clf
clear all
%process a bunch of TIFF files into a volume
%the original images were had-colored by region to one of 7 colors
%so the scalar value on the output runs from from 0 to 7
%file setup
filebase = 'e:\Audax';
startFrame = 1;
endFrame = 74;
%read frames, reduce size, show frames, and build volume
for i=startFrame:endFrame
filename=[filebase, num2str(i,'%2d'),'.tif']
temp=double(imresize(imread(filename), 0.5));
slice(:,:,i) = (temp(:,:,1)==255) + 2*(temp(:,:,2)==255) + 4*(temp(:,:,3)==255);
imagesc(slice(:,:,i));
colormap('gray')
drawnow
end
The display program computes an isosurface for each of the hand-traced structures, smooths the resulting isosurfaces, colors them, then displays them as a 3D object.
clf
clear all
%load the file with the preprocessed images
load 'c:\my documents\matlab\nichole\slice.mat'
%the original images were had-colored by region to one of 7 colors
%patch smoothing factor
rfactor = 0.125;
%isosurface size adjustment
level = .8;
%useful string constants
c2 = 'facecolor';
c1 = 'edgecolor';
%build one isosurface for each of 7 different levels
%The "slice" matrix takes on one of 7 integer values,
%so each of the following converts the data to a binary
%volume variable, then computes the isosurface between the
%1 and 0 regions
p=patch(isosurface(smooth3(slice==1),level));
reducepatch(p,rfactor)
set(p,c2,[1,0,0],c1,'none');
p=patch(isosurface(smooth3(slice==2),level));
reducepatch(p,rfactor)
set(p,c2,[0,1,0],c1,'none');
p=patch(isosurface(smooth3(slice==3),level));
reducepatch(p,rfactor)
set(p,c2,[1,1,0],c1,'none');
p=patch(isosurface(smooth3(slice==4),level));
reducepatch(p,rfactor)
set(p,c2,[0,0,1],c1,'none');
p=patch(isosurface(smooth3(slice==5),level));
reducepatch(p,rfactor)
set(p,c2,[1,0,1],c1,'none');
p=patch(isosurface(smooth3(slice==6),level));
reducepatch(p,rfactor)
set(p,c2,[0,1,1],c1,'none');
p=patch(isosurface(smooth3(slice==7),level));
reducepatch(p,rfactor)
set(p,c2,0.8*[1,1,1],c1,'none');
%lighting/image control
set(gca,'projection','perspective')
box on
lighting phong
light('position',[1,1,1])
light('position',[-1,-1,-1])
light('position',[-1, 1,-1])
light('position',[ 1,-1,-1])
%set relative proportions
daspect([1,1,1])
axis on
set(gca,'color',[1,1,1]*.6)
view(-30,30)
rotate3d on