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;endv=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) )
Best Answer