简体   繁体   English

如何将 Dicom 目录(dicom 图像系列)转换为 3D 体积图像?

[英]How can I convert Dicom directory (series of dicom images) to 3D volume image?

I have almost 80 dicom images in a folder.我在一个文件夹中有将近 80 个 dicom 图像。 Now, I want to convert these series of dicom images to a 3d volume.现在,我想将这些系列的 dicom 图像转换为 3d 卷。

Below is the code which loads MRI data, forms counter slices and then generates 3d volume.下面是加载 MRI 数据、形成计数器切片然后生成 3d 体积的代码。 But, it loads inbuilt MRI images.但是,它会加载内置的 MRI 图像。

How can I change this program to load dicom images from my folder and display 3d volume??如何更改此程序以从我的文件夹加载 dicom 图像并显示 3d 卷?

load mri
D = squeeze(D);
%figure
colormap(map)
image_num = 8;
image(D(:,:,image_num))
axis image
x = xlim;
y = ylim;
cm = brighten(jet(length(map)),-.5);
figure
colormap(cm)
contourslice(D,[],[],image_num)
axis ij
xlim(x)
ylim(y)
daspect([1,1,1])
figure
colormap(cm)
contourslice(D,[],[],[1,12,19,27],8);
view(3);
axis tight
figure
colormap(map)
Ds = smooth3(D);
hiso = patch(isosurface(Ds,5),...
   'FaceColor',[1,.75,.65],...
   'EdgeColor','none');
   isonormals(Ds,hiso)
hcap = patch(isocaps(D,5),...
   'FaceColor','interp',...
   'EdgeColor','none');
view(35,30) 
axis tight 
daspect([1,1,.4])
lightangle(45,30);
lighting gouraud
hcap.AmbientStrength = 0.6;
hiso.SpecularColorReflectance = 0;
hiso.SpecularExponent = 50;

we can use fullfile which returns a string containing the full path to the file.我们可以使用fullfile ,它返回一个包含文件完整路径的字符串。 and dir which returns a list of files and folders that match the string name.dir返回与字符串名称匹配的文件和文件夹列表。 When name is a folder, dir lists the contents of the folder.当 name 是文件夹时, dir 列出文件夹的内容。 Specify name using absolute or relative path names.使用绝对或相对路径名指定名称。 name can include wildcards (*).名称可以包含通配符 (*)。 and rest of the things are well commented in program.其余的事情在程序中得到了很好的评论。

    clear all;
    close all;
    clc;
    fileFolder = fullfile('series 9');
    files = dir ( fullfile (fileFolder, '*.dcm'));
    fileNames = {files.name};

    %examine file header (metadata , from dicom stack)

    info = dicominfo(fullfile(fileFolder,fileNames{1}));

    %extract size info from metadata
    voxel_size = [info.PixelSpacing;info.SliceThickness];

    %read one file to get size
    I = dicomread(fullfile(fileFolder,fileNames{1}));
    classI = class(I);
    sizeI = size(I);
    numImages = length(fileNames);

    %read slice images populate 3d matrix
    hWaitBar = waitbar(0,'reading dicom files');

    %create array
    mri= zeros(sizeI(1),sizeI(2), numImages , classI );
    for i=length(fileNames):-1:1
        fname = fullfile(fileFolder, fileNames{i});
        mri(:,:,i) = uint16(dicomread(fname));
        waitbar((length(fileNames)-i+1)/length(fileNames))
    end

    delete(hWaitBar);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM