how to form the volume from the single dicom image using isosurface in matlab

want to do volume rendering for the data containing dicom images . Each dicom contains again 72 frames can any one help me how to get the volume from the below code
rojectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y=72;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1: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
X(:, :, :, :, p) = imdata;
end
end
isoval=0.5;
hiso=patch(isosurface(X,isoval),...
'FaceColor',[1,0.75,0.65],'EdgeColor','none');%this is for volume display
set(hiso,'FaceAlpha',0.74);
lighting phong;
lightangle(45,30);
rotate3d on;

Réponses (2)

volumes_of_objects = squeeze( sum(sum(sum(X,1),2),3) );
Note: this assumes, though, that voxels are cubic. If your distance between z slices is different than the size of the pixels in the x and y directions, then you should multiply the above by the ratio of the z slice distance compared to the x distance. Or multiply by the physical X pixel width, physical Y pixel width, and physical Z distance: you can extract those parameters from the DICOM information structure.

14 commentaires

rror in example volume (line 21) p = patch( isosurface(v,0.5) ); after keeping the above code what you gave volumes_of_objects = squeeze( sum(sum(sum(X,1),2),3) );
What is the error message?
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y=72;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1: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
X(:, :, :, :, p) = imdata;
end
end
v=squeeze( sum(sum(sum(X,1),2),3) );
p = patch( isosurface(v,0.5) );
isonormals(v, p);
set(p, 'FaceColor','r', 'EdgeColor','none')
daspect([1 1 1])
error i got is this
Error using isosurface (line 75)
V must be a 3D array.
Error in examplevolume (line 21)
p = patch( isosurface(v,0.5) );
The volume formula I posted computes the number of occupied voxels directly. The answer is a vector of volumes, one for each file. It is not not something to run isosurface on, and it does not use any of the isosurface representation to calculate the volume (and does not care whether you have drawn the isosurface)
sir how is volume rendering and forming the volume is different i don,t the difference please can you give an idea
Volume rendering is the process of creating a graphic display from a multidimensional data set. That might include lighting and transparency considerations. It is about making something look nice.
"getting the volume" refers to calculation the amount of space occupied by a 3 or more dimensional data set. For example if you wanted to calculate the relative size of a tumor to a heart then you would want to calculate the volume. It is a numeric calculation.
sir what you said i did by keeping that volume
v=squeeze(sum(sum(sum(X,1),2),3) );
but nothing is coming can you tell how to do
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y=72;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1: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
X(:, :, :, :, p) = imdata;
v=squeeze( sum(sum(sum(X,1),2),3) );
end
end
for p = 1 : y
fig = figure();
ax = axes('Parent', fig);
v = squeeze(X(:,:,:,:,p));
hiso = patch( isosurface( v, isoval), ...
'Parent', ax, 'FaceAlpha', 0.74, ...
'FaceColor', [1,0.75,0.65],' EdgeColor', 'none', ');
lighting(ax, 'phong');
lightangle(ax, 45, 30);
rotate3d(ax, 'on');
title( sprintf('p = %d', p) )
end
sir still iam getting error iam telling frankly i don,t know any coding please help me sir
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y=72;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1: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
X(:, :, :, :, p) = imdata;
end
end
for p = 1 : y
fig = figure();
ax = axes('Parent', fig);
v = squeeze(X(:,:,:,:,p));
hiso = patch( isosurface( v, isoval), ...
'Parent', ax, 'FaceAlpha', 0.74, ...
'FaceColor', [1,0.75,0.65],' EdgeColor', 'none');
lighting(ax, 'phong');
lightangle(ax, 45, 30);
rotate3d(ax, 'on');
title( sprintf('p = %d', p) )
end
and also the error is
Undefined function or variable 'isoval'.
Error in Untitled3 (line 24)
hiso = patch( isosurface( v, isoval), ...
There is no EdgeColor property on the Patch class.
Error in Untitled3 (line 25)
hiso = patch( isosurface( v, isoval), ..
You still need
isoval=0.5;
before the "for p" loop.
projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
% y = length(projectdir);
y=72;
X = zeros(128, 128, 1, 72, y, 'uint8');
% Read the series of images.
for p=1:2: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
X(:, :, :, :, p) = imdata;
end
end
isoval=0.5;
for p = 1 : y
fig = figure();
ax = axes('Parent', fig);
v = squeeze(X(:,:,:,:,p));
hiso = patch( isosurface( v, isoval), ...
'Parent', ax, 'FaceAlpha', 0.74, ...
'FaceColor', [1,0.75,0.65],' EdgeColor', 'none');
lighting(ax, 'phong');
lightangle(ax, 45, 30);
rotate3d(ax, 'on');
title( sprintf('p = %d', p) )
end
even though iam getting here is no EdgeColor property on the Patch class.
Error in Untitled3 (line 25)
hiso = patch( isosurface( v, isoval), ...
Which MATLAB version are you using?
There definitely is an EdgeColor property for patch
https://www.mathworks.com/help/releases/R2015a/matlab/ref/patch-properties.html

Connectez-vous pour commenter.

andhavarapu lokesh
andhavarapu lokesh le 1 Déc 2016
Modifié(e) : andhavarapu lokesh le 1 Déc 2016
i wanted to display like this image by forming a volume with those images

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by