2

I am very interested in figuring out a way to describe a mesh with a function instead of triangles. This is because having a continues amount of points and normals would be very beneficial for the application I am building. However I haven't been able to figure out how it works. The mesh I have to describe varies in shape each time the application is restarted as it is reconstructed directly from live captured depth images, however the overall shape of the mesh will be approximately the same. This is the mesh of the mesh in case that makes it easier: Mesh I have looked into scipy and numpy function but in all cases it seems like I provide x and y data and then I get some z value accordingly, but since I already have x, y and z values I just want to make some sort of surface fit estimations. Any help would be much appreciated.

EDIT: With the help from @stef I found the function CloughTocher2DInterpolator, and with that I created this:

Plot of surface fit

I¨m not sure if this is a good fit or not. So if someone have some suggestions please let me know. The code I use to do this was the following:

import open3d as o3d
import numpy as np
from scipy.interpolate import CloughTocher2DInterpolator
import matplotlib.pyplot as plt

mesh = o3d.io.read_triangle_mesh("../meshPath")
pcd = mesh.sample_points_uniformly(number_of_points=2500)


o3d.visualization.draw_geometries([pcd])

points = np.asarray(pcd.points)


x = points[:,0]
y = points[:,1]
z = points[:,2]

X = np.linspace(min(x), max(x))
Y = np.linspace(min(y), max(y))
X, Y = np.meshgrid(X, Y)  # 2D grid for interpolation
interp = CloughTocher2DInterpolator(list(zip(x, y)), z, fill_value=-1.35)
Z = interp(X, Y)
#value = interp.__call__([1, 1])
fig = plt.figure()
ax = plt.axes(projection='3d')
#ax.contour3D(X, Y, Z, 75, cmap='prism')
#ax.plot_trisurf(x, y, z, cmap='viridis', edgecolor='none')
#ax.plot_wireframe(X, Y, Z, color='black')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.set_title('surface')


ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

I can plot the surface with wireframes, contour plot and so on and they all seem to look good, beside the spikes on the left side.

mikkelsen1996
  • 95
  • 1
  • 7
  • My first idea would be to use a Fourier transform. But I have no idea whether the quality of the results would be satisfying or not. – Stef Feb 14 '23 at 14:31
  • Also, how do you want the function to fit your points? There are several ways: z = f(x, y); y = f(x, z); x = f(y, z); f(x, y, z) = 0; (x, y, z) = f(theta, phi); etc. Which way is best depends on the shape of your mesh, for instance if it looks kinda like a sphere then (x, y, z) = f(theta, phi) might be best, but if it looks like a map of terrain with mountains then z = f(x, y) is best. – Stef Feb 14 '23 at 14:35
  • 1
    hi @stef the meshes that I'm working with are all representing abdomens, so I guess that the most identical shape would be a semi sphere? I have looked more into which functions would be able to describe the surface best and I found something called Three bicubic splines. However, I do not know how to get started on that at all. Do you think there is an easier approach to this? – mikkelsen1996 Feb 14 '23 at 15:14
  • 1
    You can interpolate with cubic splines using `scipy.interpolate`. See https://docs.scipy.org/doc/scipy/tutorial/interpolate.html and https://stackoverflow.com/questions/31543775/how-to-perform-cubic-spline-interpolation-in-python . I suggest using representation x =f(y, z), assuming x = front-to-back, y = left-to-right, z=toe-to-head. – Stef Feb 14 '23 at 15:21
  • Oops sorry, I meant x=back-to-front. Doesn't really matter. – Stef Feb 14 '23 at 15:47
  • hi @stef. Sorry for the very late reply I have been very busy. I have tried to get scipy to work now and the function that ended up working pretty well for me was the [basic links](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CloughTocher2DInterpolator.html#scipy.interpolate.CloughTocher2DInterpolator:scipy.interpolate.CloughTocher2DInterpolator]. However I'm still not sure if there is a function which is better at fitting to my surface? I have edited my main question to include the result I've got from using the scipy function so you can see how it looks. – mikkelsen1996 Feb 20 '23 at 14:02

1 Answers1

1

You may like to try FindSurface Web Demo.URL.

FindSurface Web Demo.PNG

The point data file must be either of XYZ or OBJ format.

If your object surface is of human body, I recommend you the following parameter values.

Input point parameter values.PNG

  • Measurement Accuracy: 5-10 mm
  • Mean Distance: 10-20 mm
  • Touch Radius: 100-150 mm.

Then,

  1. Select the model type of sphere
  2. Click a point in the spherical object surface area.

How does work the FindSurface runtime library is explained at FindSurface runtime library.URL.

I work for CurvSurf, Inc. developing the FindSurface runtime library.

The FindSurface runtime library is a software product of CurvSurf, Inc., South Korea. This library's ownership is solely on CurvSurf, Inc. and anyone can use it for non-commercial purposes. Contact to 'support at curvsurf dot com' for commercial use of the library.

Joon
  • 11
  • 4