![]() |
In this article, we’ll create a program to convert a black & white image i.e grayscale image to a colour image. We’re going to use the Caffe colourization model for this program. And you should be familiar with basic OpenCV functions and uses like reading an image or how to load a pre-trained model using dnn module etc. Now let’s discuss the procedure that we’ll follow to implement the program. Steps:
What is the L channel and ab channel? Basically like RGB colour space, there is something similar, known as Lab colour space. And this is the basis on which our program is based. Let’s discuss what it is briefly: What is Lab Colour Space?Like RGB, lab colour has 3 channels L, a, and b. But here instead of pixel values, these have different significances i.e :
And In our program, we’ll use the L channel of our image as input to our model to predict ab channel values and then rejoin it with the L channel to generate our final image. Below is the implementation of all the steps I have mentioned above. Implementation:Python3
Output:![]() image source pexels -free stock image What’s next?
You can try reading the original research paper which implemented this technique – http://richzhang.github.io/colorization/ or, you can create your own model instead of using a pre-trained model.
|
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |