Matlab中批读取DCM文件

Matlab中批读取DCM文件

  • 1. 利用cd读取路径
  • 2. 利用dir读取文件夹的文件名
  • 3. 代码

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,图像处理,dicom,医学图像,批训练)