How to read multiples DICOM images

hi,
can u tell me the procedure of reading multiple dicom images from a folder??
I have a folder named as 'Images', and dicom images are there, so i want to load these images in matlab.
I shall be thankful...

1 Comment

http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

Sign in to comment.

 Accepted Answer

dicomlist = dir(fullfile(pwd,'Images','*.dcm'));
for cnt = 1 : numel(dicomlist)
I{cnt} = dicomread(fullfile(pwd,'Images',dicomlist(cnt).name));
end

19 Comments

sir thank u so much...
what is pwd ?
dont we have to provide the folder path where dicom images are located??
pwd is command to identify current folder..
So, you don't need to write complete path.
Worked great.. thnx alot..
how can i read the images from that directory
i got it sir,,,, thank u so much...
can u tell how can i convert each image into row vector and than store all the row vectors in one matrix....
i wrote this code but certain errors came...
for num = 1:numel(dicomlist)
J{num}=I{num}(1,end);
end
??? Index exceeds matrix dimensions.
Error in ==> loaddir at 10
J{num}=I{num}(1,end);
??? Index exceeds matrix dimensions.
Did you try to vectorize that?
No, wrong way.
You can't use 'J{num}=I{num}(1,end); '
I'll give you simple way to convert matrix into vector
A = magic(2);
B = zeros(1,4);
idk = 1;
for x = 1 : size(A,1)
for y = 1 : size(A,2)
B(idk) = A(x,y);
idk = idk + 1;
end
end
Or maybe try this :
J{num} = I{num}(1:end);
Not
J{num}=I{num}(1,end);
i have matrix of 512*512 so,
A=magic(512);
B=zeros(1,262144); %as 512*512=262144
is this correct
gr8 sir,
J{num} = I{num}(1:end); it worked gr8
I am so thankful... :)
can in retrieve that vectorize matrix to the original image??
It depends.
If you know the original size (m x n), then you can convert it back to matrix.
oh yes i think i get it,
if i segment the matrix on every 512 element to next row, than i think i can get back the original image.
images i am using are 512*512
Salam! How do you retrieve original images. I have the same problem as you but for me I think the code above works fine. But I am confuse, If that works for all images in folder named "images". I want to get all 64 MR images from my folder images for further processing.
Please!
dicomlist = dir(fullfile(pwd,'Images','*.dcm'));
for cnt = 1 : numel(dicomlist)
I{cnt} = dicomread(fullfile(pwd,'Images',dicomlist(cnt).name));
end
Hi Chandra, i done write this command in new script.m
What is the Command to write in command window?
hello,
dicomlist = dir(fullfile(pwd,'Images','*.dcm'));
for cnt = 1 : numel(dicomlist)
I{cnt} = dicomread(fullfile(pwd,'Images',dicomlist(cnt).name));
end
In this program, if i want to read 10 images from a folder, which type of changes are needed?
what is the significance of "pwd" ?
shivan artosh
shivan artosh on 27 Mar 2020
Edited: shivan artosh on 27 Mar 2020
Hello Bhavna
for loop from 1 to 10

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!