如何通过在 matlab 中对 3D 对象进行三角测量来计算面积? [英] How to calculate the area by triangulating a 3D object in matlab?

查看:33
本文介绍了如何通过在 matlab 中对 3D 对象进行三角测量来计算面积?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个地方的新手,所以如果我问的问题已经在这里回答了,请原谅我.

I'm new to this place, so please forgive me if I'm asking a question already answered here.

我想计算由 3D 矩阵在 MATLAB 中给出的 3D 对象的面积,该 3D 矩阵具有对象的值 10 为背景.

I would like to calculate the area of a 3D-object given in MATLAB by a 3D-matrix with values 1 for the object and 0 for the background.

我尝试了 convhulln(K),它计算对象的凸包,然后总结不同三角形的面积.但由于我的物体通常不是凸面的,因此低估了面积.

I tried with convhulln(K), which calculates a convex hull to the object, and afterwards summing up the areas of the different triangles. But since my object is in general not convex, this gives an underestimation of the area.

我尝试的另一个选项是计算暴露"在背景中的对象的体素面积.这很好用,但高估了面积,因为体素表示只是真实物体的近似.

Another option I tried is just calculating the area of the voxels of the object "exposed" to the background. This works nice, but overestimates the area, since the voxelwise representation is only an approximation of the real object.

是否可以以非凸的方式对 3D 对象的表面进行三角剖分,以便可以通过将各个三角形的面积相加来计算面积?

Is it possible to triangulate the surface of the 3D-object in a non-convex way, so that the area can be calculated by summing up the areas of the individual triangles?

欢迎任何帮助!

推荐答案

是的,您可以使用 MATLAB 中的 isosurface() 函数对对象的表面进行三角测量.由于您的对象为 1,背景为 0,您可以这样做以对表面进行三角测量:

Yes, you can triangulate the surface of the object using the isosurface() function in MATLAB. Since your object is 1 and background is 0, you could do this to triangulate the surface:

FV = isosurface(yourMatrix, 0.5);

FV 将是一个包含曲面三角形的面和顶点的结构体.由于三角形的面积可以计算为其两条边的叉积的大小的一半,因此表面的总面积可以计算为:

FV will be a struct that contains the faces and vertices of triangles of the surface. Since the area of a triangle can be calculated as half the magnitude of the cross-product of two of its sides, the total area of the surfaces can be computed as something like:

V = FV.vertices;
F = FV.faces;
A = V(F(:, 2), :) - V(F(:, 1), :);
B = V(F(:, 3), :) - V(F(:, 1), :);
C = cross(A, B, 2);
area = 1/2 * sum(sqrt(sum(C.^2, 2)));

上面的代码假设矩阵的每个元素代表对象内的一个单位立方体.如果不是这种情况,您可以适当地缩放 AB.

The above code assumes that each element of your matrix represents a unit cube within the object. If this is not the case, you may scale A and B appropriately.

这篇关于如何通过在 matlab 中对 3D 对象进行三角测量来计算面积?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆