MATLAB Answers

Surface area calculation for irregular shape

23 views (last 30 days)
Afsaneh on 12 Nov 2014
Edited: Akira Agata on 18 Jul 2019
Hi guys. I work on 3d medical images and I extracted specious area from each slice. After 2D segmentation 3d reconstruction is done to create suspected areas. I need to calculate surface area of segmented image(3D)? If any body has any Idea, please help me.
Best regards Afsaneh

1 Comment

Elina Kapoor on 17 Jul 2019
Any updates?

Sign in to comment.

Answers (1)

Akira Agata on 18 Jul 2019
Edited: Akira Agata on 18 Jul 2019
How about the following?
%% Example in the following page
% https://jp.mathworks.com/help/matlab/visualize/visualizing-volume-data.html
load mri D % load data
D = squeeze(D); % remove singleton dimension
limits = [NaN NaN NaN NaN NaN 10];
[x, y, z, D] = subvolume(D, limits); % extract a subset of the volume data
[fo,vo] = isosurface(x,y,z,D,5); % isosurface for the outside of the volume
[fe,ve,ce] = isocaps(x,y,z,D,5); % isocaps for the end caps of the volume
figure
p1 = patch('Faces', fo, 'Vertices', vo); % draw the outside of the volume
p1.FaceColor = 'red';
p1.EdgeColor = 'none';
p2 = patch('Faces', fe, 'Vertices', ve, ... % draw the end caps of the volume
'FaceVertexCData', ce);
p2.FaceColor = 'interp';
p2.EdgeColor = 'none';
view(-40,24)
daspect([1 1 0.3]) % set the axes aspect ratio
colormap(gray(100))
box on
camlight(40,40) % create two lights
camlight(-20,-10)
lighting gouraud
%% Calculate are of the red surface
% Extract vertices and faces of the patch object
verts = p1.Vertices;
faces = p1.Faces;
% Calculate area of each triangle, and sum them
a = verts(faces(:, 2), :) - verts(faces(:, 1), :);
b = verts(faces(:, 3), :) - verts(faces(:, 1), :);
c = cross(a, b, 2);
area = 1/2 * sum(sqrt(sum(c.^2, 2)));
% Display the result
fprintf('\nThe surface area is %f\n\n', area);
>>
The surface area is 7560.636129

0 Comments

Sign in to comment.

Sign in to answer this question.