how to create 3-D volume of selected DICOM images ?

Hello , I have written a MATLAB code for the operation of converting selected DICOM images into its corresponded 3D volume . But I am not getting any response for longer time as it should complete its execution in limited time . I checked 'mri.mat' and its variable 'D' for reference . Please tell me where i should do correction in my code ? My code is -
clear all
close all
[filename, pathname] = uigetfile( ...
{'*.dcm','DCM Files (*.dcm,)';
'*.dcm', 'DICOM Images (*.dcm)'; ...
'*.*', 'All Files (*.*)'}, ...
'MultiSelect', 'on',...
'Pick file/(s)');
file_len = length(filename);
for i=1:file_len
I{i} = dicomread(filename{i});
Q{i}=imresize(I{i},0.4);
end
II = cell2mat(Q);
AA=uint8(II);
save('new1.mat','II','AA');
load new1.mat;
K = squeeze(AA);
L = padarray(K,[10 10 10],'both');
% Create an isosurface
Ds = smooth3(L);
surface = isosurface(Ds,5);
% Display the surface
hiso = patch('Vertices',surface.vertices,...
'Faces',surface.faces,...
'FaceColor',[.2,.8,.9],...
'EdgeColor','none');
grid on;
view(27,14)
axis tight
daspect([1,1,.35])
lightangle(40,30);
set(gcf,'Renderer','zbuffer'); lighting phong
isonormals(Ds,hiso)
set(hiso,'SpecularColorReflectance',0,'SpecularExponent',50)
Thank you :)

 Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Sept. de 2015
Your code
for i=1:file_len
I{i} = dicomread(filename{i});
Q{i}=imresize(I{i},0.4);
end
II = cell2mat(Q);
is creating II (and therefor the later AA) by concatenating the data long the second dimension. I suspect you wanted to concenate along the third dimension. If so then right before the above for loop insert
Q = cell(1,1,file_len);
Also I do not understand why you later squeeze(AA). Which dimension might be singleton?
When I am reading other people's code, I am more comfortable with them using permute() or reshape() rather than squeeze(), at least if it is not very obvious that one dimension has just been made singleton and the other dimensions are definitely not singleton. When the reader of the code does not know ahead of time what the dimensions of the data are to be, the reader of the code must assume that squeeze() could be operating upon an unexpected dimension, such as if it turned out that the data only had a single row. permute() and reshape() remove the possibility of changing any dimension not explicitly intended to be changed.

8 comentarios

yogesh jain
yogesh jain el 14 de Sept. de 2015
OK , Mr. Roberson Thank you for your consideration . Now could you please tell me how to run this code precisely ? Is creating montage of images necessary ? and how to create montage after re-sizing the images ? Thank you :)
I see no reason why creating a montage would be needed. I would just insert that line
Q = cell(1,1,file_len);
immediately before
for i=1:file_len
The rest of the code looks to me as if it would work from there.
The one other thing I would do is rename the variable you currently name "surface", as surface() is the name of the MATLAB routine to create 3D surface graphics. People reading the code will get confused about whether the variable name is intended to refer to the MATLAB routine.
yogesh jain
yogesh jain el 14 de Sept. de 2015
Hello sir , Actually I am confused at some of the steps , can you summarize me about the whole procedure if possible . thank you
[filename, pathname] = uigetfile( ...
{'*.dcm','DCM Files (*.dcm,)';
'*.dcm', 'DICOM Images (*.dcm)'; ...
'*.*', 'All Files (*.*)'}, ...
'MultiSelect', 'on',...
'Pick file/(s)');
file_len = length(filename);
Q = cell(1,1,file_len);
for i = 1:file_len
I{i} = dicomread(filename{i});
Q{i} = imresize(I{i},0.4);
end
II = cell2mat(Q);
AA = uint8(II);
%save('new1.mat','II','AA');
%load new1.mat;
K = squeeze(AA);
L = padarray(K,[10 10 10],'both');
% Create an isosurface
Ds = smooth3(L);
i_surface = isosurface(Ds,5);
% Display the surface
hiso = patch('Vertices', i_surface.vertices,...
'Faces', i_surface.faces,...
'FaceColor', [.2,.8,.9],...
'EdgeColor', 'none');
grid on;
view(27,14)
axis tight
daspect([1,1,.35])
lightangle(40,30);
set(gcf,'Renderer','zbuffer'); lighting phong
isonormals(Ds,hiso)
set(hiso, 'SpecularColorReflectance', 0, 'SpecularExponent', 50)
yogesh jain
yogesh jain el 15 de Sept. de 2015
Thanks a lot Mr. Roberson for your help , It proved very fruitful to me . :)
ACH Amina
ACH Amina el 24 de Abr. de 2018
Editada: ACH Amina el 24 de Abr. de 2018
How to save the 3d image obtained in dcm extension ?
In the code, it says that :
Q{i}=imresize(I{i},0.4);
But I am not quite understand why it needs to resize the model by a factor of 0.4, can you briefly explain this?
Thanks, Ringo
That imresize() was there in the original, so I presume that the original poster had some good reason for it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Sept. de 2015

Comentada:

el 7 de Mayo de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by