Slice 3D Volume into 2D Image along the specific axis
9 views (last 30 days)
Show older comments
Hello everone,
I'm trying to perform in image-analysis.
Suppose I have faces data of the volume (Faces) corresponding with Coordinate (Coords) which attached in this topic.
By using the following code,
%% Plot 3D Image
fv.faces = Faces;
fv.vertices = Coords;
patch(fv,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'b', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
camlight('headlight');
material('dull');
axis equal; axis tight;
xlabel('x');ylabel('y');zlabel('z');
view([30,30,30])
I obtained the plotted result as (with some of disappeared volume in the red circle)
Now, I want to slices this volume along the Z-axis to obtain the picture in XY-plane filled with black color.
I'm try to construct with the code as
%% Plot 2D sliced images
colors = [0 0 0];
close all;
spc = max(Coords(:,3))-min(Coords(:,3));
RangeZ = 5; % Define number of slices in Z-axis
for i = 1 : RangeZ
Coordi = DOMAIN.NODES;
Coordi(:,3) = Coordi(:,3) / RangeZ + spc/RangeZ*(i-1);
S.Vertices = Coordi;
S.Faces = Faces;
S.FaceVertexCData = colors;
S.FaceColor = 'flat';
S.EdgeColor = 'red';
S.LineWidth = 1;
figure
patch(S);
view([30,30,30])
xlabel('x');ylabel('y');zlabel('z');
axis([min(Coordi(:,1)) max(Coordi(:,1)) min(Coordi(:,2)) max(Coordi(:,2)) min(Coordi(:,3)) max(Coordi(:,3))]);
end
However, the results that shown below in the left side are not sliced (Just plot the whole volume in different range of Z-axis).
I want to slices the above volume along Z- axis as depicted in the right side ( I drawn the picture by myself for easy to understand).
>>>>>>>>>>
>>>>>>>>>>
I've been struggle with this problem for a very long time.
Any suggestions, Ideas are very very appreciated.
Thanks in advances.
4 Comments
yanqi liu
on 11 Feb 2022
slices this volume along the Z-axis to obtain the picture in XY-plane filled with black color.
may be use view(2) after crop by Coordi(:,3) = Coordi(:,3) / RangeZ + spc/RangeZ*(i-1);
Answers (1)
Simon Chan
on 15 Feb 2022
Edited: Simon Chan
on 15 Feb 2022
Actually you did it in the first plot, just add the following line in 2D sliced images plots.
And use the original axis ranges.
patch(S);
view([30,30,30])
axis equal; axis tight; % Add this line
xlabel('x');ylabel('y');zlabel('z');
axis([min(Coords(:,1)) max(Coords(:,1)) min(Coords(:,2)) max(Coords(:,2)) min(Coords(:,3)) max(Coords(:,3))]); % Use the original xyz limts
0 Comments
See Also
Categories
Find more on 3-D Volumetric Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!