how to save multiple dicom images in a folder?

Sir,
I have 500 Dicom images in the folder. I will read image one by one and save all the images in another folder.
I can read the multiple images. But, how to save all the dicom images in another folder one by one.
Thank you.

 Accepted Answer

Stalin Samuel
Stalin Samuel on 13 Jan 2015
Edited: Stalin Samuel on 13 Jan 2015

6 Comments

Thank you so much.
Hi Jothi.
I have the problem to read multiple dicom images in a folder.
can you share with me the script and the command?
projectdir = '.'; %full name of directory images are in
dinfo = dir( fullfile(projectdir, '*.dcm') );
nfile = length(dinfo);
filenames = fullfile(projectdir, {dinfo.name});
dimages = cell(nfile,1);
for K = 1 : nfile
thisfile = filenames{K};
try
dimages{K} = dicomread(thisfile);
catch ME
fprintf('There was some problem reading file "%s", continuing anyhow\n', thisfile);
end
end
I did not assume that all of the files can be read or that all of the files will have images exactly the same size and same number of frames.
In the special case that the images are all readable and same amount of info, then
imgdims = ndims(dimages{1});
all_dimages = cat(imgdims+1, dimages{:});
This is the another way of reading multiple images in a folder.
dir_path = 'F:\sample_image\';
dir_path = strcat(dir_path,'\');
dirpath = strcat(dir_path,'*.dcm');
files = dir(dirpath);
file_names={files.name};
sf=size(file_names);
for ii=1:sf(2),
s1 = strcat(dir_path,char(file_names{ii}));
Input_Image=imread(s1);
end
That is pretty much the same as what I showed, but only works on MS Windows; the version I posted works on all operating systems.
Also, the question was specifically about dicom images, which require dicomread() rather than imread()
I have digital image data and want to extract it in a format .dicom??

Sign in to comment.

More Answers (0)

Categories

Asked:

on 13 Jan 2015

Commented:

r r
on 23 Jul 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!