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 Kommentar

Walter Roberson
Walter Roberson am 30 Dez. 2011
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011

4 Stimmen

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

19 Kommentare

Usama Javed
Usama Javed am 30 Dez. 2011
sir thank u so much...
what is pwd ?
dont we have to provide the folder path where dicom images are located??
Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011
pwd is command to identify current folder..
So, you don't need to write complete path.
Usama Javed
Usama Javed am 30 Dez. 2011
Worked great.. thnx alot..
how can i read the images from that directory
Usama Javed
Usama Javed am 30 Dez. 2011
i got it sir,,,, thank u so much...
Usama Javed
Usama Javed am 30 Dez. 2011
can u tell how can i convert each image into row vector and than store all the row vectors in one matrix....
Usama Javed
Usama Javed am 30 Dez. 2011
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.
Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011
Did you try to vectorize that?
No, wrong way.
You can't use 'J{num}=I{num}(1,end); '
Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011
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
Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011
Or maybe try this :
J{num} = I{num}(1:end);
Not
J{num}=I{num}(1,end);
Usama Javed
Usama Javed am 30 Dez. 2011
i have matrix of 512*512 so,
A=magic(512);
B=zeros(1,262144); %as 512*512=262144
is this correct
Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011
perfect!
Usama Javed
Usama Javed am 30 Dez. 2011
gr8 sir,
J{num} = I{num}(1:end); it worked gr8
I am so thankful... :)
Usama Javed
Usama Javed am 30 Dez. 2011
can in retrieve that vectorize matrix to the original image??
Chandra Kurniawan
Chandra Kurniawan am 30 Dez. 2011
It depends.
If you know the original size (m x n), then you can convert it back to matrix.
Usama Javed
Usama Javed am 30 Dez. 2011
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
naila
naila am 26 Jul. 2013
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!
mohd akmal masud
mohd akmal masud am 6 Nov. 2017
Bearbeitet: Walter Roberson am 27 Mär. 2020
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?
Bhavna Pancholi
Bhavna Pancholi am 19 Jun. 2018
Bearbeitet: Walter Roberson am 27 Mär. 2020
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 am 27 Mär. 2020
Bearbeitet: shivan artosh am 27 Mär. 2020
Hello Bhavna
for loop from 1 to 10

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu DICOM Format finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by