loading...
  1. Difference between Point and Matrices

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 row-major-order which is

Following conventional matrix notation, rows are numbered by the first index of a two-dimensional 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/Row-major_order#Explanation_and_example

As in mathematics, row:0, column:0 is the top-left element of the matrix. Row/column are just like in tables…


1
2
3
4
5
6
7
0/0---column--->
 |
 |
row
 |
 |
 v

2. For Points a coordinate system is chosen that fulfils two things: 1. it uses the same unit-sizes and the same “origin” as the matrix notation, so top-left is Point(0,0) and axis length 1 means the length of 1 row or 1 column. 2. it uses “image notation” for axis-ordering, which means that abscissa (horizontal axis) is the first value designating the x-direction and the ordinate (vertical axis) is the second value designating the y-direction.

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 y-axes defined is often referred to as the Cartesian plane or xy plane. The value of x is called the x-coordinate or abscissa and the value of y is called the y-coordinate 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/0---X--->

but since we want to have that origin in top-left and positive values to go to bottom, it is instead:


1
2
3
4
5
6
7
0/0---X--->
 |
 |
 Y
 |
 |
 v

So for us, row-first notation might be weird, but for mathematicians x-axis-first 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 !!





Leave a Reply

Your email address will not be published. Required fields are marked *

Welcome to OpenCV World !! Come as a Guest, stay as a Family