Can we read dicom files without extension using the dicomread function?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have 71 image slices and the idea is to make an image volume using these slices. I tried using the following:
close all; clear; clc
%%
Folder = '/etc/';
filenames = fullfile(Folder,'Z*'); % files names are Z01, Z02, ....., Z75
findDir = dir(filenames);
total_Im = numel(filenames);
%%
for n = 1:total_Im
f = fullfile(Folder,filenames(n).name);
dm_images = dicomread(f);
figure(n)
imshow(dm_images)
end
% How can I read these files without extension and make a single image
% volume?
0 Kommentare
Akzeptierte Antwort
Rik
am 28 Jun. 2022
Store the read images in a 3D array. That way you will have the entire volume in one variable, allowing you to do further processing as you need to.
clear dm_images
for n = 1:total_Im
f = fullfile(Folder,filenames(n).name);
dm_images(:, :, n) = dicomread(f);
end
4 Kommentare
Rik
am 29 Jun. 2022
I would suggest using the debugger to go through your code line by line. Then you would discover your first loop doesn't do anything. You would also find out that your file name variable doesn't actually contain a file name, but is instead a struct. That makes dicomread assume it is a dicominfo struct.
Folder = '/etc/';
findDir = fullfile(Folder,'*');
filenames = dir(findDir);
total_Im = length(filenames);
clear dm_images
for n = 1:total_Im
f = fullfile(Folder,filenames(n).name);
dm_images(:, :, n) = dicomread(f);
end
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!