0
1

More than 1 year has passed since last update.

1チャンネルのnumpy配列を3チャンネルに変換する

Posted at

チャンネルの次元がない場合

例えば

>>> image.shape
(64, 64)

のような場合

img = np.stack((img,)*3, axis=-1)

チャンネルの次元がある場合

例えば

>>> image.shape
(64, 64, 1)

のような場合

img = np.repeat(img, 3).reshape(img.shape[0],img.shape[1],3)

numpy初心者すぎてこれしか思いつかないが、もっといい方法がありそうな気もする。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1