MATLAB Answers

0

how to sum all the frames in each dicom image and all the dicom images to form the volume

Asked by andhavarapu lokesh on 27 Nov 2016
Latest activity Commented on by Star Strider
on 27 Nov 2016
an any one help me how to do this I has 72 dicom images in a folder each dicom image has 72 frames. I wanted to aggreagate all frames of all dicom images to form a volume c
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y = 72;
Odd = zeros(128, 128, 1, 72, y, 'uint8');
Even = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1:y
thisfile = sprintf('IM_%d.dcm', p);
filename = fullfile( projectdir, thisfile);
imdata = dicomread(filename);
imsize = size(imdata);
if ~isequal( imsize, [128 128 1 72] )
fprintf('file is unexpected size %s instead of [128 128 1 72], skipping "%s"\n', mat2str(imsize), filename);
else
Odd(:, :, :, :,p) = imdata;
% Even(:, :, :, :, :,p+1)=imdata;
end
% end
end
figure();
% Display the first image stack.
z=montage(Odd(:,:,:,:,1),[]);

  1 Comment

Please learn to use the ‘[{}Code]’ button to format your code.

Sign in to comment.

0 Answers