In opencv in python I loaded an black and white image. After resize this image I added pading 5 pixel into each side of image :
resized_digit = cv2.resize(digit, (18,18))
cv2.imshow("resized Image", digit)
# Padding the digit with 5 pixels of black color (zeros) in each side to finally produce the image of (28, 28)
padded_digit = np.pad(resized_digit, ((5,5),(5,5)), "constant", constant_values=0)
How can I show padded_digit by opencv? Because when I try to show like this:
cv2.imshow("Padded Image", padded_digit)
I got this error:
<class 'list'>
Traceback (most recent call last):
File "<ipython-input-4-295bf6efa8c4>", line 39, in <module>
padded_digit = np.pad(resized_digit, ((5,5),(5,5)), "constant", constant_values=0)
File "<__array_function__ internals>", line 5, in pad
File "/home/Alt/anaconda3/lib/python3.8/site-packages/numpy/lib/arraypad.py", line 746, in pad
pad_width = _as_pairs(pad_width, array.ndim, as_index=True)
File "/home/Alt/anaconda3/lib/python3.8/site-packages/numpy/lib/arraypad.py", line 521, in _as_pairs
return np.broadcast_to(x, (ndim, 2)).tolist()
File "<__array_function__ internals>", line 5, in broadcast_to
File "/home/Alt/anaconda3/lib/python3.8/site-packages/numpy/lib/stride_tricks.py", line 180, in broadcast_to
return _broadcast_to(array, shape, subok=subok, readonly=True)
File "/home/Alt/anaconda3/lib/python3.8/site-packages/numpy/lib/stride_tricks.py", line 123, in _broadcast_to
it = np.nditer(
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (3,2)