Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is meant by img.at<uchar>(i,j)?

Tags:

c++

opencv

mat

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>
like image 334
Haris_tech Avatar asked Jan 14 '23 22:01

Haris_tech


1 Answers

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.

like image 92
sgarizvi Avatar answered Jan 18 '23 08:01

sgarizvi