Python中球面投影图像的高程畸变

2024-04-23 18:49:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着拍摄两张矩形图像,一张是可见的表面特征,另一张代表海拔,然后将它们映射到一个三维球体上。我知道如何用Cartopy将特征映射到一个球体上,我也知道如何制作relief surface maps,但我找不到一个简单的方法将它们组合起来,使其在球面投影上具有夸张的高度。例如,here's it done in MATLABExample picture

有人知道在Python中是否有一种简单的方法可以做到这一点?在


Tags: 方法图像高度代表特征surface表面maps
1条回答
网友
1楼 · 发布于 2024-04-23 18:49:03

我的解决方案不能满足您的所有要求。但首先,这可能是一个很好的开端。在

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from matplotlib.cbook import get_sample_data
from matplotlib._png import read_png

# Use world image with shape (360 rows, 720 columns) 
pngfile = 'temperature_15-115.png'

fn = get_sample_data(pngfile, asfileobj=False)
img = read_png(fn)   # get array of color

# Some needed functions / constant
r = 5
pi = np.pi
cos = np.cos
sin = np.sin
sqrt = np.sqrt

# Prep values to match the image shape (360 rows, 720 columns)
phi, theta = np.mgrid[0:pi:360j, 0:2*pi:720j]

# Parametric eq for a distorted globe (for demo purposes)
x = r * sin(phi) * cos(theta)
y = r * sin(phi) * sin(theta)
z = r * cos(phi) + 0.5* sin(sqrt(x**2 + y**2)) * cos(2*theta)

fig = plt.figure()
fig.set_size_inches(9, 9)
ax = fig.add_subplot(111, projection='3d', label='axes1')

# Drape the image (img) on the globe's surface
sp = ax.plot_surface(x, y, z, \
                rstride=2, cstride=2, \
                facecolors=img)

ax.set_aspect(1)

plt.show()

结果图像:

enter image description here

相关问题 更多 >