matlab - 在 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张图片。在此处 输入图像描述 在此处输入图像描述我不知道我的错在哪里。我将非常感谢您的帮助
解决方案
您可以稍微调整您的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);
更新后的代码现在会生成一个带有堆叠切片的图像:
推荐阅读
- svn - 已检查 SVN 存储库的文件夹未显示绿色、红色勾号图标
- raspberry-pi - GPS数据解析
- azure - 如何从 ASP.NET MVC5 从 Azure BLOB 存储下载文件
- android - 在 android api 17 以下有 looper.quitSafely() 的替代方案吗?
- azure-machine-learning-studio - 在 Azure 机器学习工作室中替换数据集中的值
- node.js - Unhandled Rejection: Headers cant be set after they are sent
- angular - Angular2使用for循环调用http post方法
- html - 没有 domlistner 地图不显示
- java - Java 视频流项目
- html - 引导网格输出与预期不同