次の形状のマルチスペクトル画像があるとします:
a = np.random.random([240, 320, 30])
テール軸は次の分数波長での値を表します:
array([395.13, 408.62, 421.63, 434.71, 435.64, 453.39, 456.88, 471.48,
484.23、488.89、497.88、513.35、521.38、528.19、539.76、548.39、
557.78、568.06、577.64、590.22、598.63、613.13、618.87、632.75、
637.5、647.47、655.6、672.66、681.88、690.1])
次のように整数波長でデータを再グリッド化するために、すべての単一波長を反復せずに、最も効率的なものは何ですか:
array([400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520,
530、540、550、560、570、580、590、600、610、620、630、640、650、
660、670、680、690])
お試しいただけるオプションをご紹介します。
numpy を np としてインポート
補間として scipy.interpolate をインポートします
a = np.random.random([240, 320, 30])
波長1 = np.array([395.13, 408.62, 421.63, 434.71, 435.64, 453.39, 456.88, 471.48,
484.23、488.89、497.88、513.35、521.38、528.19、539.76、548.39、
557.78、568.06、577.64、590.22、598.63、613.13、618.87、632.75、
637.5、647.47、655.6、672.66、681.88、690.1])
波長2 = np.array([400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520,
530、540、550、560、570、580、590、600、610、620、630、640、650、
660、670、680、690])
interp = interpolate.RegularGridInterpolator((np.arange(a.shape[1]), np.arange(a.shape[0]), 波長), a.transpose((1, 0, 2)))
#上記の整数波長に基づいて新しいグリッドを作成します
X、Y = np.meshgrid(np.arange(320)、np.arange(240))
a2 = a.copy()
ix の場合、enumerate(wavelengths2) の val:
a2[:, :, ix] = interp((X, Y, 値))