我想在文件夹中显示所有dicom文件。当我运行以下代码来显示所有dcm文件时,MATLAB显示所有像素值为零的空白窗口。 Sub1文件夹包含150个dcm文件。
编辑:问题不在于代码。我刚刚在另一组DCM图像上尝试了这个代码,这些图像是256x256并且它可以工作。但是它没有使用一组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
答案 0 :(得分: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
答案 1 :(得分:0)
设置项目目录,如下例所示:
projectdir = ['F:\MS Study\Thesis\Implementation\Dataset\Dcm\Sub1' filesep];
dicomFiles = dir( fullfile(projectdir, '*.dcm' ));;