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.

Get Discount on Top Educational Courses

Brand NameDiscount InformationCoupon Codes Link
Educative.io20% discount on Educative courses and plans
W3Schools20% discount on W3Schools courses
KodeKloud10% discount on KodeKloud courses and plans
GeeksforGeeks30% discount on GeeksforGeeks courses
Target Test Prep20% discount on Target Test Prep
Coding Ninjas₹5000 discount on Coding Ninjas courses
Skillshare40% discount on Skillshare
DataCamp50% discount on DataCamp
365 Data Science57% discount on 365 Data Science Plans
Get SmarterFlat 20% discount on Get Smarter courses
SmartKeedaFlat 40% discount on SmartKeeda courses
StackSocial20% discount on StackSocial courses

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

Drawing Chhatrapati Shivaji Maharaj Using Python Chhatrapati Shivaji Maharaj, the legendary Maratha warrior and founder of the Maratha Empire, is an inspiration …

Resume Builder Application using Java With Source Code Graphical User Interface [GUI] Introduction: The Resume Builder Application is a powerful and user-friendly …

Encryption Tool using java with complete source Code GUI Introduction: The Encryption Tool is a Java-based GUI application designed to help users …

Movie Ticket Booking System using Java With Source Code Graphical User Interface [GUI] Introduction: The Movie Ticket Booking System is a Java …

Video Call Website Using HTML, CSS, and JavaScript (Source Code) Introduction Hello friends, welcome to today’s new blog post. Today we have …

promise day using html CSS and JavaScript Introduction Hello all my developers friends my name is Gautam and everyone is welcome to …

Get Huge Discounts
More Python Projects