7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

3次元配列の結合numpy.dstack

Last updated at Posted at 2017-11-19

3次元配列の結合 dstack

三次元目で結合してくれる。

a.shape #((640, 480, 1))
b.shape #((640, 480, 1))
np.dstack((a, b))
# ((640, 480, 2))

opencvでBGRのBだけを取得して、他のGRを全部0で作られた画像を作成。

img = cv2.imread('363.jpg') #(640, 480, 3)
ze = np.zeros((640, 480,1))

blue = img[:,:,:1]
blue = np.dstack((blue, ze))
blue = np.dstack((blue, ze))
print(blue.shape)
print(blue[:,:,1])

cv2.imshow('blue', blue[:,:,1])
cv2.waitKey(0)

もちろん画像はめっっちゃ青

7
6
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
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?