第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使用線性插值插入 numpy 數(shù)組

如何使用線性插值插入 numpy 數(shù)組

我有一個(gè) numpy 數(shù)組,它具有以下形狀:(1, 128, 160, 1)。現(xiàn)在,我有一個(gè)具有以下形狀的圖像:(200, 200)。因此,我執(zhí)行以下操作:orig = np.random.rand(1, 128, 160, 1)orig = np.squeeze(orig)現(xiàn)在,我想要做的是獲取我的原始數(shù)組并將其插入到與輸入圖像相同的大小,即(200, 200)使用線性插值。我想我必須指定應(yīng)該評估 numpy 數(shù)組的網(wǎng)格,但我無法弄清楚如何去做。
查看完整描述

1 回答

?
至尊寶的傳說

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊

你可以這樣做scipy.interpolate.interp2d:


from scipy import interpolate


# Make a fake image - you can use yours.

image = np.ones((200,200))


# Make your orig array (skipping the extra dimensions).

orig = np.random.rand(128, 160)


# Make its coordinates; x is horizontal.

x = np.linspace(0, image.shape[1], orig.shape[1])

y = np.linspace(0, image.shape[0], orig.shape[0])


# Make the interpolator function.

f = interpolate.interp2d(x, y, orig, kind='linear')


# Construct the new coordinate arrays.

x_new = np.arange(0, image.shape[1])

y_new = np.arange(0, image.shape[0])


# Do the interpolation.

new_orig = f(x_new, y_new)

注意形成x和時(shí)對坐標(biāo)范圍的 -1 調(diào)整y。這確保圖像坐標(biāo)從 0 到 199(含)。


查看完整回答
反對 回復(fù) 2021-12-17
  • 1 回答
  • 0 關(guān)注
  • 184 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)