Mat is short form for "Matrice" and it is the central type used to store images and other things in openCV. You should really learn those very basics if you want to work with openCV. The documentation of openCV is quite good. See for example here:
http://docs.opencv.org/modules/core/doc/basic_structures.html[
^]
With the constructor as shown in your code:
Mat sampleMat = (Mat_<float>(1,2) << i,j);
you create a matrice with 2 elements (1 row, 2 columns) and store the values of i and j into it.
"Also why in if-else conditions it uses (j,i) not (i,j) ?"
You're right it should be indexed with (i, j) and in fact that's what is done in the tutorial you'
ve linked. So it seems you made a mistake there when copying the code.