I am trying to resize some images using tensorflows image resizing method. I have a loop where I load in the image, resize and then try to write it back out using cv2.imwrite(). However, it continues to error out, does this not output an image? Here's my code:
j=0
for i in images:
skyr_img = imread(my_data_dir+'/'+str(i)) #converts image to an array
skyr_img=tf.image.resize(skyr_img,[171,256],antialias=True,method='bilinear')
print(skyr_img.shape,j)
cv2.imwrite(my_data_dir+'/train/img'+str(j),skyr_img)
j=j+1
and this is the error I get:
(171, 256, 4) 0
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-49-80ea3aae6498> in <module>
4 skyr_img=tf.image.resize(skyr_img,[171,256],antialias=True,method='bilinear')
5 print(skyr_img.shape,j)
----> 6 cv2.imwrite(my_data_dir+'/train/img'+str(j),skyr_img)
7 j=j+1
error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'imwrite'
> Overload resolution failed:
> - img is not a numpy array, neither a scalar
> - Expected Ptr<cv::UMat> for argument 'img'