Its kind a basic question. I don't know what this structure.
img.at<uchar>(i,j)
is meant to be? I try to find the definition of at
, but can't understand it. and what this syntax means?
<uchar>
Similarly, what is meant by
img.at<cv::Vec3b>(row,col)[channel]
Yes, Mat
is matrix class to manipulate matrix data. I understand the behavior of those above lines but can't understand theory behind them?
What does this syntax mean?
img.at<cv::Vec3b>
at
is an overloaded C++ template function of the class cv::Mat
.
The < >
is the syntax for invoking a C++ template.
img.at<uchar>(i,j)
The above line means, we are accessing the pixel (i,j)
and specifying its data type to be unsigned char
.
In simple English, fetch 1 pixel from index (i, j)
i.e. row number i and column number j.
img.at<cv::Vec3b>
The above is used for a 3 channel image. Same as the first one, but fetching the pixel values of all the three channels. The value returned is a Vec3b
structure containing 3 values, one for each channel.
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