Skip to content

Instantly share code, notes, and snippets.

@shamrin
Last active December 14, 2015 08:49
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 shamrin/5060209 to your computer and use it in GitHub Desktop.
Save shamrin/5060209 to your computer and use it in GitHub Desktop.
import numpy
# source data
a = numpy.ones(4000000, dtype=numpy.uint8).reshape((2000,2000))
# make gray RGB image
g = numpy.empty((2000,2000,3))
g[...] = a[..., numpy.newaxis]
# make image width divisable by 4
width = g.shape[1]
pad = -width % 4
r = numpy.lib.pad(g, ((0,0), (0,pad), (0,0)), 'constant') # SLOW!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment