Image Processing — Color Space Conversion : Part 2
BGR ↔ Gray, BGR ↔ HSV
In this article, I’m going to take you on an adventure with colors.
Today, I wanted to share about
(1). Most widely used Color-space conversion — BGR ↔ Gray, BGR ↔ HSV
(2). Object Tracking
The OpenCV offers more than 150 color-space conversion methods. In this article, we will examine the most widely used ones BGR ↔ Gray, BGR ↔ HSV.
Color conversion is performed using the
cv2.cvtColor(input_image, flag) function
flag determines the type of conversion.
For conversion, we use the following flags :
- BGR → Gray :cv2.COLOR_BGR2GRAY
- BGR → HSV :cv2.COLOR_BGR2HSV
Next, I’ll focus on…
Here I am going to create an application to extract a colored object in a video.
Here are the steps that you need to take:
Step 1: Take each frame of the video.
Step 2: Convert from BGR to HSV color space.
Step 3: We threshold the HSV image for a range of blue colors.
Step 4: Let’s extract only the blue object.
Let’s see the code now:
Option 1 :
Note: Here I’ve attached a video file for your convenience.
So that’s it for now.
Next article is about: Histograms.
Give claps if you liked this article as it would encourage me to write more and will make me happy.
Thank you guys see you soon! ❤️ ✌