How do I convert the four dimension arrays to 3 dimension variable ?

2 次查看(过去 30 天)
I read a dicom image which has 128 rows and 128 columns, a depth of 1, and each dicom has 72 frames. Like this 72 images
X(128,128,1,72);
Now I need to convert this four-dimensional variable to a 3 dimensional variable for doing volume rendering using isosurface. How do I reduce this dimension by using reshape or squeeze? Can any one help me?
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y=72;
X = zeros(128, 128, 1, 72,'uint8');
p=1;
% Read the series of images.
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
X(:, :, :, :) = imdata;
end
v=zeros(128,128,1,1);
v(128,128,1,1)=reshape(X,size);
isoval=-1.5;
y=72;
fig = figure();
ax = axes('Parent', fig);
hiso = patch( isosurface( v, isoval), ...
'Parent',ax,'FaceAlpha', 0.74, ...
'FaceColor',[0.1,0.75,0.65],'EdgeColor','none');
lighting(ax, 'phong');
lightangle(ax, 45, 30);
rotate3d(ax, 'on');
title( sprintf('p = %d', p) )

采纳的回答

KSSV
KSSV 2016-12-2
编辑:KSSV 2016-12-2
X = rand(128,128,1,72);
[m,n,p,q] = size(X) ;
Y = reshape(X,m,n,q) ;
  3 个评论
KSSV
KSSV 2016-12-2
编辑:KSSV 2016-12-2
Image not attached..look at imshow(Y(:,:,i)) where i = 1.....q

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2016-12-2
Why not just do
X = squeeze(imdata);

Community Treasure Hunt

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

Start Hunting!

Translated by