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.
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With