1
インデックス画像bins
は複数の領域で構成されています。 0
はバックグラウンドで、その他の正の値は領域です。別の配列に基づいてインデックス画像をすばやく再現する方法
私は例えば、別の配列に基づいて、各地域の値を入力します。:
bins = # image of shape (height, width), type int
ids = np.array([1, 5, ... ]) # region ids
values = np.array([0.1, ...]) # Values for each region, same shape as ids
img = np.empty(bins.shape, 'float32')
img[:] = np.nan
for i, val in zip(ids, values):
img[bins == i + 1] = val
が、このループはPythonで、超遅いです。それを素晴らしいnumpyの方法で書く方法がありますか?
ありがとうございます!ここで