Matlab中批读取DCM文件

Posted Paul-Huang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Matlab中批读取DCM文件相关的知识,希望对你有一定的参考价值。

1. 利用cd读取路径

cd     Change current working directory.
    cd directory-spec sets the current directory to the one specified.
    cd .. moves to the directory above the current one.
    cd, by itself, prints out the current directory.

    WD = cd returns the current directory as a string.
>> a=cd

a =

D:\\Administrator\\ImageProcess_Matlab

2. 利用dir读取文件夹的文件名

D = dir('directory_name') returns the results in an M-by-1 structure with the fields: 
        name    -- Filename
        date    -- Modification date
        bytes   -- Number of bytes allocated to the file
        isdir   -- 1 if name is a directory and 0 if not
        datenum -- Modification date as a MATLAB serial date number.
                   This value is locale-dependent.

3. 代码

a = cd;
dir_src=dir(a);
for i=3:1:length(dir_src)
        I=dicomread(dir_src(i).name);
%         metadata = dicominfo('**.dcm');%存储信息
%         imagesc(I);%显示图像
%         dicomwrite(I, '**.dcm',metadata);%写入Dicom图像
        figure('Units','centimeter','Position',[2+i 5 15 8.5]);
        # resize
        J = imresize(I, 5,'nearest');
        # show
        imshow(I, 'DisplayRange',[]);
        pause(0.3)
end

以上是关于Matlab中批读取DCM文件的主要内容,如果未能解决你的问题,请参考以下文章

Matlab中批读取DCM文件

如何在matlab中读取一组三维dicom图片

读取一系列dcm图片,然后重新写入

读取.dcm文件itk

DICOM入门(三)——解析DCM文件

十ITK读取一张dcm图像然后通过vtk显示