Black and White to Colour Images using Python With Source Code

Convert Black & white Image into Color using python

Introduction

Hello Curious Coders,

In this project we are going to convert the Blacka and White Image to Colour Image using Python. To do so in python we have a popular package named as CV2 which is most used to perform image related operations.

Source Code

				
					# import required package
import cv2

# Load the B&W image
img = cv2.imread('bw_image.jpg', 0)

# Apply a pseudocolor effect to the B&W image
colorized = cv2.applyColorMap(img, cv2.COLORMAP_JET)

# Save the colorized image
cv2.imwrite('colorized_image.jpg', colorized)
				
			

Code Explanation

  • First we imported the required package cv2.
  • Next, we loaded the Black and White Image using cv2.imread() function.
  • Later we colorized image using applyColorMap() function to colorize image using the COLORMAP_JET color map.
  • Finally using imwrite() function of cv2 package we stored our colorized image.

Output

Input Image:
B&W Image
Output Image
Black and White to Colour Image using Python

Find More Projects

Build a Quiz Game Using HTML CSS and JavaScript Introduction Hello coders, you might have played various games, but were you aware …

Emoji Catcher Game Using HTML CSS and JavaScript Introduction Hello Coders, Welcome to another new blog. In this article we’ve made a …

Typing Challenge Using HTML CSS and JavaScript Introduction Hello friends, all you developer friends are welcome to our new project. If you …

Breakout Game Using HTML CSS and JavaScript With Source Code Introduction Hello friends, welcome to today’s new blog post. All of you …

Digital and Analog Clock using HTML CSS and JavaScript Introduction : This project is a digital clock and stopwatch system, which allows …

Coffee Shop Website using HTML, CSS & JavaScript Introduction : This project is a website for coffee house business. It uses HTML …

Get Huge Discounts
More Python Projects

All Coding Handwritten Notes