1

Let's suppose I have an image such that

image.shape=(280,280,3)

If I do img[[[1,2],[1,2],[1,2]]].shape, I obtain (2,). But I expect to obtain (2,2,2)...

How can slicing be performed simultaneously on several dimensions in numpy?

1 Answer 1

1

You are using the Array of Indices syntax, when you probably want slices.

Try something like this:

img[1:3, 1:3, 1:3]
Sign up to request clarification or add additional context in comments.

1 Comment

That's exactly what I wanted. Thank you very much.

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.