Skip to content

Instantly share code, notes, and snippets.

@mboyanov
Created January 30, 2018 18:02
Show Gist options
  • Select an option

  • Save mboyanov/8a1a74c8f99a5571922fd5cefc1c8c58 to your computer and use it in GitHub Desktop.

Select an option

Save mboyanov/8a1a74c8f99a5571922fd5cefc1c8c58 to your computer and use it in GitHub Desktop.

Revisions

  1. mboyanov created this gist Jan 30, 2018.
    7 changes: 7 additions & 0 deletions alpha_copy.py
    Original 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