Skip to content

Instantly share code, notes, and snippets.

@CptSpaceToaster
Created October 29, 2015 01:00
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 CptSpaceToaster/b260050d4a111c185057 to your computer and use it in GitHub Desktop.
Save CptSpaceToaster/b260050d4a111c185057 to your computer and use it in GitHub Desktop.
$ python3.4
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
>>> import numpy
>>> a = numpy.array([[[127, 127, 127, 255],
... [127, 127, 127, 255]],
... [[127, 127, 127, 255],
... [127, 127, 127, 255]]])
>>> b = numpy.array([[[127, 127, 127, 255],
... [255, 0, 0, 255]],
... [[0, 255, 0, 255],
... [0, 0, 255, 255]]])
>>> ((a - b) + 255)/2
array([[[ 127.5, 127.5, 127.5, 127.5],
[ 63.5, 191. , 191. , 127.5]],
[[ 191. , 63.5, 191. , 127.5],
[ 191. , 191. , 63.5, 127.5]]])
I would like this instead
array([[[ 127, 127, 127, 127],
[ 63, 191, 191, 127]],
[[ 191, 63, 191, 127],
[ 191, 191, 63, 127]]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment