-1

I'm trying to create a multidimensional matrix with numpy, to describe a RGB image. Something like this does not work:

numpy.full(100, 100, [0,0,0])

This fails with TypeError: data type not understood. What I'm trying to get at is a pixel matrix with rgb values at every pixel.

Edit: this gets me halfway there:

n = numpy.empty((3,3,3))
n[:] = [0,0,0]

However, this gives a float array for every point, while a uint8 array would suffice. How would I fix that?

ddccffvv
  • 133
  • 1
  • 6
  • Possible duplicate of [Initializing numpy matrix to something other than zero or one](https://stackoverflow.com/questions/1704823/initializing-numpy-matrix-to-something-other-than-zero-or-one) – jotasi Jul 27 '18 at 09:17

1 Answers1

0

Apparently, this does the trick:

n = numpy.empty((3,3,3))
n[:] = numpy.array([0,0,0], dtype=numpy.uint8)
ddccffvv
  • 133
  • 1
  • 6