0

我想在一个文件夹中显示所有 dicom 文件。当我运行以下代码来显示所有 dcm 文件时,MATLAB 会显示所有像素值为零的空白窗口。Sub1 文件夹包含 150 个 dcm 文件。

编辑:问题不在于代码。我刚刚在另一组 256x256 的 DCM 图像上尝试了此代码并且它有效。但它不适用于一组特定的 512x512 dcm 文件。会不会有分辨率问题?谢谢

  projectdir = 'F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1';
  dicomFiles = dir( fullfile(projectdir, '*.dcm' ));
  y = length(dicomFiles);
  %X = zeros(128, 128, 1, y, 'uint8');
  % Read the series of images.

  for p=1:y
      filename = fullfile( projectdir, dicomFiles(p).name );
      Y = dicominfo(filename);
      Y2 = dicomread(Y);
      imshow(Y2, []);
  end
4

2 回答 2

1

我会推荐这个:

projectdir = 'F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1\';
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));
y = length(dicomFiles)
%X = zeros(128, 128, 1, y, 'uint8');
% Read the series of images.
for p=1:y
  filename = fullfile([ projectdir, dicomFiles(p).name ]);
  Y = dicominfo(filename);
  Y2 = dicomread(Y);
  imshow(Y2, []);
 end
于 2016-11-24T09:57:49.960 回答
0

像下面的例子一样设置你的项目目录:

projectdir = ['F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1' filesep]; 
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));;
于 2016-11-24T09:55:28.503 回答