'how can I Convert a grey sketch image to color sketch?

I have a image converted into sketch. I am trying to convert the black and white sketch into a red and white image. Is this is able with opencv? The image I have: The original image and the sketched image in black color is this.

As you can see, the image is sketched in black. I am trying to sketch it in red or green or any other color rather than black. I looked all over the internet but could not find a way to achieve this. I know this question is very bad but please do bear with me and I am really grateful to any who can at least give me a hint to start my work. Thank you very much.



Solution 1:[1]

Quick guide rather than fully tested answer.

Load the image as greyscale:

import cv2
import numpy as np

grey = cv2.imread(YOURIMAGE, cv2.IMREAD_GRAYSCALE)

Now make empty channel of same size to use for Green and Red channels

empty = np.zeros_like(grey)

Stack the grey image as Blue and two blank channels as Green and Red

colourImage = np.dstack((grey, empty, empty))

Change the order of the 3 innermost parameters in that last line to get different colour effects. Or add 64, or 128 or 255 to either of the empty images for other effects.


So, if you stack per my answer above, you'll get:

enter image description here


If you invert the Blue channel and stack like this:

colourImage = np.dstack((~grey, empty, empty))

enter image description here


If you save the Blue channel and stack with 50% Green and 100% Red like this:

res = np.dstack((grey,empty+128,empty+255))

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1