0

我有一个 3D 图像。我需要对该图像进行球面波分解,因此我需要将笛卡尔网格中的 3d 图像转换为球坐标。

如果下面的内容太长而无法阅读,我想要的要点是我想要一个映射球面坐标的映射,这样,尤其是在我的原点附近,我没有很多缺失的信息。

首先,我进行球面转换。

    [ydim,xdim,zdim] = size(myimg);

    [x,y,z] = meshgrid(1:xdim, 1:ydim, 1:zdim);
    x = x - median(x(:)); y = y - median(y(:)); z = z - median(z(:)); 
    [phis, thetas, rs] = cart2sph(x,y,z);

从这里我被困住了。我如何使用我的 phis 和 thetas 以及 r 沿着弧线进行插值(我只是假设它是弧线,因为它是一个球体)。

我实际上对此进行了一些搜索,并将这段代码放在一起进行插值,但我无法验证它是否有效。主要是因为大部分是从类似的问题中复制和修改的。

function [theta0,phi0,rho0] = my_interp(X, Y, Z, nTheta0, nPhi0)
% forget about spherical, let's just interpolate in cartesian then convert 
% to spherical. 
[theta, phi, V] = cart2sph(X, Y, Z);

% X,Y,Z are meshgrid output from above code snippet.
P = [2 1 3];
X = permute(X, P);
Y = permute(Y, P);
Z = permute(Z, P);
V = permute(V, P);

% create a cartesian interpolant, and we'll use it in spherical.
F = griddedInterpolant(X,Y,Z,V);

% prepare grid for meshing (we'll mesh xyz data, not theta,phi)
theta0 = linspace(-pi, pi, nTheta0);
phi0   = linspace(-pi/2, pi/2, nPhi0);
[theta0, phi0] = meshgrid(theta0, phi0);

[x_,y_,z_] = sph2cart(theta0, phi0, 1 ); % !! here is why I get confused. my 
% radius on the sphere is not just 1, I have changing radius. Am I really     
% missing the key insight here? On the other hand, I don't know how to      
% account for all the r's on the image anyways so I can't change this.
rho0 = F(x_,y_,z_);

theta0 = repmat(theta0, 1, 1, size(X, 3));
phi0 = repmat(phi0, 1, 1, size(X, 3));
rho0 = repmat(rho0, 1, 1, size(X, 3));
end
4

1 回答 1

0

您不想创建一个笛卡尔坐标网格并将其转换为球面坐标,而是创建一个球面坐标网格,将其转换为笛卡尔坐标,然后用于interp3查找这些坐标处的图像值。

球坐标网格可能类似于meshgrid(0:maxR,0:phiStep:2*pi,0:thetaStep:pi).

于 2017-11-27T02:17:24.990 回答