Is there any built-in tool that allows you to make the correct conversion of an array of the form [100, 100, 4] to [4, 100, 100] . A simple np.reshape() incorrect result.

  • Do you need to arrange the seeds in the reverse order? or sort? - pavel
  • there is an image in 100x100 with 4 channels - I get [100, 100, 4], I need [4, 100, 100] - lao712
  • @ lao712, then add your answer - so that the question does not hang as without an answer - gil9red

1 answer 1

answer

 np.rollaxis(array, 2).reshape(3, width, height)