Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying OpenCV Essentials
  • Table Of Contents Toc
OpenCV Essentials

OpenCV Essentials

By : Suarez
4.3 (13)
close
close
OpenCV Essentials

OpenCV Essentials

4.3 (13)
By: Suarez

Overview of this book

This book is intended for C++ developers who want to learn how to implement the main techniques of OpenCV and get started with it quickly. Working experience with computer vision / image processing is expected.
Table of Contents (10 chapters)
close
close
9
Index

Conversion from RGB to other color spaces


The color of an image may also be modified by changing the color space. In OpenCV, six color models are available and it is possible to convert from one to another by using the cvtColor function.

Note

The default color format in OpenCV is often referred to as RGB but it is actually BGR (the channels are reversed).

The function void cvtColor(InputArray src, OutputArray dst, int code, int dstCn=0) has the input and output images as the first and second parameters. The third parameter is the color space conversion code and the last parameter is the number of channels in the output image; if this parameter is 0, the number of channels is obtained automatically from the input image.

The following color_channels example shows how to convert from RGB to HSV, Luv, Lab, YCrCb, and XYZ color spaces:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;
using namespace std;

int main( ){
    Mat image, HSV, Luv, Lab,...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
OpenCV Essentials
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon