0
$\begingroup$

I want to convert my grey mnist to color. I have came up with the following code, but the output is still gray.

# 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')

Before and after

Can comeone point me in the right direction?

Thanks! :)

$\endgroup$

1 Answer 1

0
$\begingroup$

Have you tried this tutorial to colour the image?

https://www.pyimagesearch.com/2019/02/25/black-and-white-image-colorization-with-opencv-and-deep-learning/#download-the-code

You need to train your model first and then you can convert the image to colour using 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)```

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.