Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-channel matrix/array

I've been reading about openCV recently and its cv::Mat data structure. In the documentation, the author keeps mentioning about multi-channel array and multi-channel matrix. Can some one give me a definition of those two, and what is a "channel"? I tried to find on google but found nothing similar.

like image 995
hphp95 Avatar asked Feb 13 '16 15:02

hphp95


1 Answers

The most basic example is a standard image. It has a width (cols), a height (rows) and 3 color channels.

Mat myImg = imread("color_picture.jpg");
Vec3b pixel = myImg.at<Vec3b>(y, x);

In this case, myImg will be a CV_8UC3 -- 3 channels of 8 bit, unsigned integers.

I prefer to use the templated class, because I feel it's more clear:

Mat_<Vec3b> myImg = imread("color_picture.jpg");
// Or, Mat3b myImg = ...
Vec3b pixel = myImg(y, x);

Then, pixel is Blue, Green, Red:

uchar blue = pixel[0];
like image 136
Geoff Avatar answered Sep 23 '22 04:09

Geoff