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
- AI & Space Exploration – AI’s Role in Deep Space Missions and Planetary Research
- SQL Joins Explained: A Complete Guide with Examples
- 10 Awesome Data Science Blogs To Check Out
- Top 15 Recommended SEO Tools
- Top 10 Blogs of Digital Marketing you Must Follow
- Understanding AI, ML, Data Science, and More: A Beginner's Guide to Choosing Your Career Path
- Understanding HTAP Databases: Bridging Transactions and Analytics
- Datasets for Natural Language Processing
- Python Challenging Programming Exercises Part 3
- Ideas for Content of Every niche on Reader’s Demand during COVID-19
Prepare for Interview
Datasets for Machine Learning
- 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