Reputation: 1
I am using the following code to resize an image, but am getting unexpected results. I am also attaching the output screenshots. Can someone explain why this is happening?
import cv2
import tensorflow as tf
import matplotlib.pyplot as plt
test_img = cv2.imread('deer12.jpeg')
test_img = cv2.cvtColor(test_img,cv2.COLOR_BGR2RGB)
plt.imshow(test_img, cmap=plt.cm.binary)
plt.show()
test_img=tf.image.resize(test_img,(32,32))
plt.imshow(test_img, cmap=plt.cm.binary)
plt.show()
Upvotes: 0
Views: 128
Reputation: 485
Watch out for the messages which are displayed... They might be warnings.
"Clipping indput data..." - this suggests that you should normalize the image.
import cv2
import tensorflow as tf
import matplotlib.pyplot as plt
test_img = cv2.imread('deer12.jpeg')
test_img = cv2.cvtColor(test_img,cv2.COLOR_BGR2RGB)
plt.imshow(test_img, cmap=plt.cm.binary)
plt.show()
test_img = test_img / 255.0 # this one
test_img=tf.image.resize(test_img,[32,32])
plt.imshow(test_img, cmap=plt.cm.binary)
plt.show()
Upvotes: 1