3D volume formation & display using 2D image stack
5 views (last 30 days)
Show older comments
I have 931x1060x123 image stack (double). This comes from a .lif file and constitutes 3D structures. The stack width, height and depth are 3221.0966 (931p), 3667.4140 (1060) and 615.0984 (123) microns. The voxel size is 3459.8x3459.8x5000.8 and the resolution is 0.2890 pixels per micron. I want to display it as a 3D volume. So far I have done this:
clearvars
close all
clc
addpath ('C:\zmf\data')
addpath ('C:\zmf\code')
rootdir = 'C:\zmf';
cd ([rootdir '\data'])
data = dir('*Kidney83.tif');
fname = data.name;
info = imfinfo(fname);
load microscopeSpecs.mat
metadata = microscopeSpecs;
metadataKeys = metadata.keySet().iterator();
for i=1:metadata.size()
key = metadataKeys.nextElement();
value = metadata.get(key);
str = strfind(key, '|');
if strcmp(key(str(end)+1:end), 'Begin') == 1
zmax = str2double(value);
end
if strcmp(key(str(end)+1:end), 'End') == 1
zmin = str2double(value);
end
fprintf('%s = %s\n', key, value)
end
ImageSizeReductionFactor = 1;
I = zeros(ceil(info(1).Width*ImageSizeReductionFactor), ...
ceil(info(1).Height*ImageSizeReductionFactor), length(info));
for i = 1 : length(info)
im = double(imread(fname, i));
im = imrotate(im, -90);
im = imresize(im, ImageSizeReductionFactor);
I(:,:,i) = double(im);
names = strrep(fname, '_', '\_');
% Display results
imagesc(I(:,:,i))
colormap(jet)
title([names ', Slice : = ' num2str(i)])
pause(0.001)
end
%%Display 3D volume
xlength = info(1).XResolution*info(1).Width;
ylength = info(1).YResolution*info(1).Height;
zlength = abs(zmax-zmin)*10e3;
xvec = repmat(0:info(1).XResolution:xlength, info(1).Height, 1);
yvec = repmat(0:info(1).YResolution:ylength, info(1).Width, 1);
[faces,vertices]= isosurface(I);
figure;
patch('Faces',faces,'Vertices',vertices)
grid on
colormap copper
but it does not render a 3D volume correctly using isosurface() and I cannot assign a face color myself. It appears all black plus some interpolation stuff removes some data that I wan to visualize.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160921/image.jpeg)
However, if I use ImageJ plugin (3D Viewer), I don't have to do anything and it displays the volume correctly:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160922/image.jpeg)
So I want to display something like this. How can I correlate my pixel values and voxel size information to create voxels such that I get a 3D volume? Or is there a possibility to display the stack correctly like ImageJ plugin did without voxel generation for the whole volume?
Best regards,
0 Comments
Answers (1)
Isaac
on 4 Mar 2021
Hey, I'm running into the same problem right now. Were you able to solve this?
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!