Difference between Point and Matrices
Hello all,
This is my favorite topic as most of the people get confused while plotting the x and y coordinates for their image.
Let’s start with the basic Mathematics. In mathematics, we have the following things:
1) Matrices, which contains (number of rows) and (number of columns)
2) Graphs (of functions), which have multiple axes and graphically represent the graph in form of an image.
3) Points, which are ordered by the axes of the coordinate system which normally is a Cartesian coordinate
But, what are these? here is the explanation:
1. For Matrices the mathematical notation is to order in rowmajororder which is
Following conventional matrix notation, rows are numbered by the first index of a twodimensional array and columns by the second index, i.e., a1,2 is the second element of the first row, counting downwards and rightwards. (Note this is the opposite of Cartesian conventions.)
Taken from http://en.wikipedia.org/wiki/Rowmajor_order#Explanation_and_example
As in mathematics, row:0, column:0 is the topleft element of the matrix. Row/column are just like in tables…
1
2
3
4
5
6
7 0/0column>


row


v
2. For Points a coordinate system is chosen that fulfils two things: 1. it uses the same unitsizes and the same “origin” as the matrix notation, so topleft is Point(0,0) and axis length 1 means the length of 1 row or 1 column. 2. it uses “image notation” for axisordering, which means that abscissa (horizontal axis) is the first value designating the xdirection and the ordinate (vertical axis) is the second value designating the ydirection.
The point where the axes meet is the common origin of the two number lines and is simply called the origin. It is often labeled O and if so then the axes are called Ox and Oy. A plane with x and yaxes defined is often referred to as the Cartesian plane or xy plane. The value of x is called the xcoordinate or abscissa and the value of y is called the ycoordinate or ordinate.
The choices of letters come from the original convention, which is to use the latter part of the alphabet to indicate unknown values. The first part of the alphabet was used to designate known values.
http://en.wikipedia.org/wiki/Cartesian_coordinate_system#Two_dimensions
so in a perfect world we would choose the coordinate system of points/images to be:
1
2
3
4
5
6
7 ^


Y


0/0X>
but since we want to have that origin in topleft and positive values to go to bottom, it is instead:
1
2
3
4
5
6
7 0/0X>


Y


v
So for us, rowfirst notation might be weird, but for mathematicians xaxisfirst would be strange to access a matrix.
So in OpenCV you can use:
1  mat.at<type>(row,column) 
or
1  mat.at<type>(cv::Point(x,y)) 
to access the same point if
1  x=column 
and
1  y=row 
which is perfectly comprehensible
Hope that helps !!