0

I have converted the image into a NumPy array. Then uses np.rot90 to rotate the array to 90 degrees.

img90 = np.array(np.rot90(image))
img90.shape

The output I receive is --> (256, 4, 256) But I want it to be (4, 256, 256)

I have tried

img90 = np.rollaxis(img90, 1, 0)
img90.shape

But the output is not fixed, sometimes it gives (256, 4,256) and sometimes (4, 256, 256)

1
  • 2
    what is the input, and as far as I know code should return the same thing every time :)) Commented Aug 9, 2022 at 11:51

1 Answer 1

1

You should specify the axes axes and number of rotation k parameters

assuming your array size is 256x256x4:

img0 = np.rot90(img0, axes=(0,2), k= 1)
print(img0.shape)
>>> (4, 256, 256)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.