OpenCV Python Color Spaces Introduction

In this OpenCV Python article we are going to talk about Color Spaces Introduction.  if you are interested in Python GUI Development, you can check the below links.

 

 

Also you can read more articles on Python GUI Development

1: PyQt5 GUI Development Tutorials

2: Pyside2 GUI Development Tutorials

3: wxPython GUI Development Tutorials

4: Kivy GUI Development Tutorials 

 

 

There are more than 150 color-space conversion methods available in OpenCV. But we will look into only two which are most widely used ones, BGR ↔ Gray and BGR ↔ HSV.

For color conversion, we use the function cv.cvtColor(input_image, flag) where flag determines the type of conversion.

For BGR → Gray conversion we use the flags cv.COLOR_BGR2GRAY. Similarly for BGR → HSV, we use the flag cv.COLOR_BGR2HSV. To get other flags, just run following commands in your Python terminal :

 

 

 

This is the complete source code for this article

 

 

 

 

These lines of codes are for converting our Color Spaces.

 

 

 

And these line of codes are for showing of our images, basically we are going to show the images in different colors.

 

 

 

 

Run the complete code and this will be the result

OpenCV Python Color Spaces Introduction
OpenCV Python Color Spaces Introduction

 

 

 

 

 

Also you can watch the complete video tutorial for this article

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×