Extract RGB Color From a Image Using CV2

Hi Everyone, We are Come Back with a New Post, In this post, We learn How to Extract RGB Color From an Image. In Simple Language Convert an Image Into Red, Green and Blue Color.
We Use CV2 Library for Extract RGB Color From an Image. There are Few Steps to Extract RGB Color from an Image.
- Import Library
- Read Image
- Split Image to RGB
- Show Image
Necessary Library
- CV2
- Numpy
#import library
import cv2
import numpy as np
#Read Image
img = cv2.imread('logo.png')
cv2.imshow('Output Image1', img)
cv2.waitKey(0)
#Split Image
B,G,R = cv2.split(img)
zero = np.zeros(img.shape[:2],dtype ='uint8')
cv2.imshow('Red', cv2.merge([zero,zero,R]))
cv2.waitKey(0)
cv2.imshow('Green', cv2.merge([zero,G,zero]))
cv2.waitKey(0)
cv2.imshow('Blue',cv2.merge([G,zero,zero]))
cv2.waitKey(0)
cv2.destroyAllWindows()
Download Source Code
Thanks for Reading Share this
Random Blogs
- Understanding SQL vs MySQL vs PostgreSQL vs MS SQL vs Oracle and Other Popular Databases
- Big Data: The Future of Data-Driven Decision Making
- Mastering SQL in 2025: A Complete Roadmap for Beginners
- Datasets for Exploratory Data Analysis for Beginners
- Why to learn Digital Marketing?
- Time Series Analysis on Air Passenger Data
- The Ultimate Guide to Artificial Intelligence (AI) for Beginners
- Career Guide: Natural Language Processing (NLP)
- Downlaod Youtube Video in Any Format Using Python Pytube Library
- Transforming Logistics: The Power of AI in Supply Chain Management
Prepare for Interview
- JavaScript Interview Questions for 0–1 Year Experience
- JavaScript Interview Questions For Fresher
- SQL Interview Questions for 5+ Years Experience
- SQL Interview Questions for 2–5 Years Experience
- SQL Interview Questions for 1–2 Years Experience
- SQL Interview Questions for 0–1 Year Experience
- SQL Interview Questions for Freshers
- Design Patterns in Python
- Dynamic Programming and Recursion in Python
- Trees and Graphs in Python
- Linked Lists, Stacks, and Queues in Python
Datasets for Machine Learning
- Amazon Product Reviews Dataset
- Ozone Level Detection Dataset
- Bank Transaction Fraud Detection
- YouTube Trending Video Dataset (updated daily)
- Covid-19 Case Surveillance Public Use Dataset
- US Election 2020
- Forest Fires Dataset
- Mobile Robots Dataset
- Safety Helmet Detection
- All Space Missions from 1957
- OSIC Pulmonary Fibrosis Progression Dataset
- Wine Quality Dataset
- Google Audio Dataset
- Iris flower dataset
- Artificial Characters Dataset
- Bitcoin Heist Ransomware Address Dataset