1

I am processing images in python and for a specific purpose I've been asked to "make numpy arrays with these dimensions: 32x3x512x512 (patches x color channels, height, width)." I don't have any problem getting any of the data, but I just cannot picture the structure of the numpy array. My best approaches are: Option 1, Option 2 . And I may be not even close.

Any better idea on how the numpy array should look?

1 Answer 1

1

You can literally take the problem description and use it as the shape of the array:

arr = np.empty((32, 3, 512, 512), 'u1')

Now arr[0] is the first patch (i.e. first image), and has the shape (3, 512, 512), so it's 24 (3x8) bits per pixel, and the dimensions are 512 x 512 pixels.

Some people might use a different ordering of the dimensions, such as (32, 512, 512, 3), but it really depends on the processing you eventually want to do.

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.