How to interpolate between two 3D shapes?

15 views (last 30 days)
Prabhjot Juneja
Prabhjot Juneja on 28 Jul 2015
Edited: Bruno Luong on 22 Apr 2022
I have been struggling to find a method that will allow me to interpolate between two 3D surfaces. Basically, one surface (empty bladder) is totally inside another surface (full bladder) and I want to define surfaces interpolated between these two surfaces. I will really appreciate any guidance.
  1 Comment
John Kearns
John Kearns on 22 Apr 2022
Edited: Bruno Luong on 22 Apr 2022
Prabhjot,
Did you ever find a way to address this? This concept has recently become useful in my own research and if you have a solution I'd be grateful if you shared your approach.
Cheers

Sign in to comment.

Answers (2)

Kelly Kearney
Kelly Kearney on 30 Jul 2015
I would convert your surfaces into spherical coordinates with the origin at the center of your two bladder surfaces, then interpolate the surfaces onto the same azimuth/elevation grid. After that you'll have a one-to-one match between the vertices of your surfaces that you can use for interpolation.
  1 Comment
Prabhjot Juneja
Prabhjot Juneja on 31 Jul 2015
Thank Kelly, I tried something similar to this but had an issue in the regions curvature was complex. For example if you have two point at different radial distance but at the same polar & azimuth angles. Then establishing correspondence becomes difficult. However, with spherical coordinates I can apply logic to correctly identify correspondence. I will give it go. My data is a point cloud but can be converted to triangulated mesh if needed. If I dont find any simpler approach, I will try deformable registration.

Sign in to comment.


Matt Cohen
Matt Cohen on 30 Jul 2015
Hi Prabhjot,
I understand that you are trying to define surfaces by interpolating data between two surfaces. I am not sure exactly what form you are using to represent and store your 3D surfaces in MATLAB. I am assuming you are representing these surfaces as some function z = f(x,y) over some grid of XY values.
Let's say we have two surfaces, z1 and z2, defined over XY grids. These two surfaces can be interpolated by smoothing them with some smoothing factor 'a': z3 = a*z1 + (1-a)*z2. The smoothing factor determines how much weight each surface gets when computing the new surface values. Using a range of 'a' values, a set of surfaces can be defined as different interpolations of the original two surfaces.
I have included example code and plots below to show how this can be accomplished using MATLAB. There are two cases to consider here: one where surfaces z1 and z2 are defined over the same XY grid, and one where the XY grid points differ. The "surface" function is being used to produce the surface plots. The resulting plots for each case are displayed below the code. A single smoothing factor (a = 0.3) is being used here.
Case 1: Same XY grid
% Create two initial surfaces (same grid)
[x,y] = meshgrid(-2:0.2:2,-2:0.2:2);
z1 = x.*exp(-x.^2 - y.^2);
z2 = z1 + 1;
figure
h1 = surface(x,y,z1);
hold on
h2 = surface(x,y,z2);
view(3)
% Interpolate between the two surfaces
a = 0.3;
hold on
h3 = surface(x,y,(a*z1+ (1-a)*z2));
Case 2: Different XY grids
% Create two initial surfaces (different grids)
[x1,y1] = meshgrid(-2:0.4:2,-2:0.4:2);
[x2,y2] = meshgrid(-2:0.2:2,-2:0.2:2);
z1 = x1.*exp(-x1.^2 - y1.^2);
z2 = x2.*exp(-x2.^2 - y2.^2) + 1;
figure
h1 = surface(x1,y1,z1);
hold on
h2 = surface(x2,y2,z2);
view(3)
% Interpolate surface z1 in the finer grid defined for surface z2
z1_interp = interp2(x1,y1,z1,x2,y2);
a = 0.3;
hold on
h3 = surface(x2,y2,(a*z1_interp + (1-a)*z2));
The only difference between the two cases is the way in which the smoothing is handled. This difference is due to the different XY grids in the second example. In order to smooth the two surfaces, they must first be defined over the same XY grid, meaning the surfaces have the same number of points and are defined at the same (x,y) coordinates. The "interp2" function can be used to interpolate a surface over a different set of coordinate values. In the example above, the surface with less fine detail (smaller number of grid points) is interpolated over the finer grid. Then, the interpolated surface is smoothed with the surface defined over the finer grid, producing the overall smoothed surface.
Since a = 0.3 is the smoothing factor here, the smoothed surface should lie closer to the upper surface. The plots show this expected outcome. Additionally, in the second plot, the lower surface has a less smooth appearance, which is a result of having a coarser grid.
I hope this helps.
Matt
  1 Comment
Prabhjot Juneja
Prabhjot Juneja on 31 Jul 2015
Hi Matt, thank you for the very clear potential solutions. Apologies for not clarifying the data. My data is a point cloud (x,y,z) and each point represent a point on the surface (bladder). I have two sets of point and I want to interpolated between these sets. If I put them in a grid, there would be different number of points and also the grind locations would be different. I will give a spherical coordinates a go as suggested in previous comment. If I dont find any simpler approach, I will try deformable registration.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!