Reputation: 193
I have an array with shape (64,64) in Python and I want to repeat these elements (three times) in the way that I could have an array with the shape (64,64,3). Any idea?
Upvotes: 0
Views: 323
Reputation: 477318
Probably the most simplest way to accomplish this here is by using numpy.dstack
:
import numpy as np
b = np.dstack((a, a, a))
where a
was the original array (shape 64×64), and b
is the new array (shape 64×64×3).
Upvotes: 1