0

I have (5000, 32, 32, 3) as numpy.ndarray. (number of images:5000, image size: (32x32), channel: 3)

I want to resize the image (32x32) to (28x28). How can I do this?

1

1 Answer 1

1

I would use scipy.ndimage.zoom().

Something like:

import scipy.ndimage

factor = 28.0 / 32.0
scipy.ndimage.zoom(input_array, (1, factor, factor, 1))
Sign up to request clarification or add additional context in comments.

2 Comments

Do note that zoom is "lazy" when downsampling, not properly averaging over pixels and hence losing some information.
Sure, running a uniform (or other) filter prior to to zoom would indeed be a good idea.

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.