I have a bunch of (greyscale) images of different sizes that I resize to ensure one dimension is the same and pad the other dimension (a la this answer). Yet, I get the error ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (3,2)
on the 4th line (second to last line) of the code below. How would I solve this?
I tried running on non-greyscale images (as suggested here), yet this still doesn't work.
My code:
image = cv2.imread(filepath)
width = int((height / image.shape[1]) * image.shape[0])
image = cv2.resize(image, (width, height), interpolation = cv2.INTER_AREA)
image = np.pad(image,((0,0), (0,1028 - image.shape[1])), mode = 'constant')
data.append(image)