Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mboyanov
Created January 30, 2018 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mboyanov/8a1a74c8f99a5571922fd5cefc1c8c58 to your computer and use it in GitHub Desktop.
Save mboyanov/8a1a74c8f99a5571922fd5cefc1c8c58 to your computer and use it in GitHub Desktop.
Utility to copy the alpha channel from a 4d numpy image to a 3d numpy image
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
@prettydeep
Copy link

I'm having trouble integrating alpha_copy into neural_style.py. Could you please share the full script you used for the work you did here? Any help you could provide would be very much appreciated. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment