필터 지우기
필터 지우기

2D Slices of Mesh Generated Using Trimesh

조회 수: 41 (최근 30일)
Frank Fazekas
Frank Fazekas 2022년 5월 25일
답변: VINAYAK LUHA 2023년 12월 1일
I have created a 3D surface mesh of volumetric microscopy data (nuclei) using the iso2mesh toolbox. I'm trying to evaluate the quality of the mesh by comparing it to the 2D input image slice by slice. iso2mesh has a "plotmesh" function which is quite useful for visualizing the mesh in 3D. This function ultimately calls the MATLAB builtin "trimesh."
However, viewing 2D slices of the mesh is proving challenging. If the zlim is set to a particular range, the outline of the mesh becomes extremely faint. If I then try to overlay the original image slice with imagesc, it becomes very difficult to see the 2D slice of the mesh. I have attached examples of the 3D mesh and the 2D slice below. Is there a better method of visualizing 2D slices of the mesh, either with a well-defined outline or with an interior?

답변 (1개)

VINAYAK LUHA
VINAYAK LUHA 2023년 12월 1일
Hi Frank,
I understand that you have a 3D surface mesh created using MATLAB "trimesh" function. Additionally, you want to visualize the 2D slices along the z axis of the mesh with clear outlines and filled interiors.
To achieve this, you can utilize MATLAB's "contourf" function to generate filled contour plot that display the x-y outlines of the 3D mesh at any given z-axis value.
Following is the code snippet demonstrating the above-mentioned approach-
% Define the 3D surface
[x,y] = meshgrid(1:15,1:15);
z = peaks(15);
T = delaunay(x,y);
trimesh(T,x,y,z)
% Define the z value at which you want to plot the contour
z_value = 1;
[x_plane, y_plane] = meshgrid(0:0.1:15, 0:0.1:15);
z_plane = z_value*ones(size(x_plane));
% Plot the plane at z=z_value
hold on;
title("3D mesh and the 2D cross-section plane")
surf(x_plane, y_plane, z_plane, 'FaceAlpha', 0.5, 'EdgeColor', 'none');
hold off
% Plot the contour at the given z value
contourf(x, y, z, [z_value z_value], 'LineColor', 'r', 'LineWidth', 1);title("2D cross-section of the 3D mesh");
Further, refer to the following documentation for more details on how to use the “contourf” function –
Hope this helps you in plotting the 2D cross sections of your 3D plot.
Best Regards,
Vinayak Luha

카테고리

Help CenterFile Exchange에서 Triangulation Representation에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by