Created
January 30, 2018 18:02
-
-
Save mboyanov/8a1a74c8f99a5571922fd5cefc1c8c58 to your computer and use it in GitHub Desktop.
Revisions
-
mboyanov created this gist
Jan 30, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ def copy_alpha(source, target): new_shape = np.copy(target.shape) new_shape[2] = 4 fourd = np.zeros(new_shape, dtype=np.uint8) fourd[:, :, 3] = source[:, :, 3] # copy the alpha channel fourd[:, :, :3] = target[:, :, :3] #copy the content return fourd