在 Matlab 中表示来自 2D 图像的 3D 体积图像

Represent a 3D volume image from 2D images in Matlab

我应该在 Matlab 中表示来自 2D 图像的 3D 体积图像。 2D 图像的数量为 90 张 DICOM 格式的图像。 此外,每张图片大小为512 * 512。此任务是关于Z轴上切片之间的距离。 这是我的以下代码:

**

clear variables
clear all
close all
names=dir('C:\Users\User\Desktop\Projekt-DICOM-Daten von einem Cone-Beam CT (CBCT)\CT.Test CatPhan 
CBCT A\*.dcm');
for i=1:size(names,1) %names is a struct consists of 90 * 1.
       
I(:,:,i)=dicomread(strcat('C:\Users\User\Desktop\Projekt-DICOM-Daten von einem Cone-Beam CT 
 (CBCT)\CT.Test CatPhan CBCT A\',names(i).name));
  
for j=1:size(names,1)
Img_3D=surface('XData',[0 256;0 256],'YData',[0 0;256 256],'ZData', 
[jj;jj],'CData',flipdim(im2double(I(:,:,i)),1),'FaceColor','texturemap','EdgeColor','none');
colormap(gray) 
xlabel('x')
ylabel('y')
zlabel('z')
end
end

**

我必须取消程序以便它给我图片。否则不添加图片需要更长的时间。 当程序退出时,它会显示一个图像体积,但你有相同的图像(完全黑色)。然而,90 个原始图像是不同的。 我上传了2张图片。enter image description here enter image description here我不知道我的错在哪里。 我将非常感谢你的帮助

您可以稍微调整您的 surface() 调用:

% Simulate OP's data with example data supplied by the Image Processing Toolbox
[alldata,cmap]=dicomread('US-PAL-8-10x-echo.dcm');
I=nan(size(squeeze(alldata)));
for i=1:size(alldata,4) %although not necessary in this example, this loop tries to mimic the structure of OP's code
  I(:,:,i)=alldata(:,:,:,i); %this line corresponds to OP's dicomread(strcat(...))
end
clear i;

for i=1:size(alldata,4)
  Img_3D=surface('XData',(1:size(I,2))-1,'YData',(1:size(I,1))-1, ...
    'ZData',(i-1)*ones(size(I(:,:,i))),'CData',flipud(im2double(I(:,:,i))), ...
    'FaceColor','texturemap','EdgeColor','none');
end
colormap(cmap);
clear i I alldata cmap;
xlabel('x');
ylabel('y');
zlabel('z');
zlim([-Inf Inf]);
view(30,30);

更新后的代码现在生成具有堆叠切片的图像: