0

I have an image of shape [h,w,3]. I want to make a square center crop of this image, that is an array of shape [min(h,w), min(h,w),3]. I'm using numpy. What I tried is this:

def image_center_crop(img):


cropped_img = np.reshape(img, (np.minimum(img.shape[0],img.shape[1]), np.minimum(img.shape[0],img.shape[1]),3))

return cropped_img

However, I'm getting an error ValueError: total size of new array must be unchanged. How can I reshape my array?

Caims
  • 107
  • 3

0 Answers0