Skip to content

Instantly share code, notes, and snippets.

@mntone
Created August 21, 2015 23:13
Show Gist options
  • Select an option

  • Save mntone/3062e85495443356c6f9 to your computer and use it in GitHub Desktop.

Select an option

Save mntone/3062e85495443356c6f9 to your computer and use it in GitHub Desktop.
これをforじゃなくてnumpyで書いたらどうなるかわかる人教えて
#!python
import copy
import numpy as np
image = cv2.imread('x.png', cv2.IMREAD_UNCHANGED)
height, width = image.shape[:2]
cimage = np.empty((height, width, 3), dtype = np.uint8)
for h in range(height):
for w in range(width):
if image[h, w, 3] == 0:
cimage[h, w] = [0x00, 0x00, 0x00]
else:
cimage[h, w] = image[h, w, 0:3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment