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

问题描述

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

**

clear variables
clear all
close all
names=dir('C:\Users\User\Desktop\Projekt\2-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\2-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))-1,...
    'ZData',(i-1)*ones(size(I(:,i))),'CData',flipud(im2double(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);

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

Image