我想把我的灰色菜单转换成彩色。我想出了下面的代码,但是输出仍然是灰色的。
# Import
(train_images0, train_labels0), (test_images, test_labels) = tensorflow.keras.datasets.fashion_mnist.load_data()
# Split
train_images, val_images, train_labels, val_labels = train_test_split(train_images0, train_labels0, test_size=0.20)
#Convert to color BGR
output = cv2.cvtColor(train_images[88],cv2.COLOR_GRAY2BGR)
#Show before and after
plt.imshow(output)
plt.show()
plt.imshow(train_images[88],cmap='gray')
能把我引向正确的方向吗?
谢谢!:)
发布于 2021-11-24 00:56:36
你试过这个教程来给图像上颜色吗?
您需要先训练您的模型,然后才能使用cv2将图像转换为颜色。
# load the input image from disk, scale the pixel intensities to the
# range [0, 1], and then convert the image from the BGR to Lab color
# space
image = cv2.imread(args["image"])
scaled = image.astype("float32") / 255.0
lab = cv2.cvtColor(scaled, cv2.COLOR_BGR2LAB)```https://datascience.stackexchange.com/questions/104415
复制相似问题