Created
August 21, 2015 23:13
-
-
Save mntone/3062e85495443356c6f9 to your computer and use it in GitHub Desktop.
これをforじゃなくてnumpyで書いたらどうなるかわかる人教えて
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!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