This serves as a memo. In openCV,

- Points is in the order of (x,y);
- Size is in the oder of (width,height);

However, - Matrix is accessed in the order of (row,col)
- Image is stored in the order of (height, width)

For example, in

cv2.resize(image, dsize, interpolation=cv2.INTER_AREA)

dsize is the output (destination, ergo d) image size in the order of (width, height).

cv2.warpAffine(image, M, dsize)

M is the 2×3 transformation matrix, dsize is the output image size in the order of (w, h). According to the documentation of warpAffine,

x' = M_11 * x + M_12 * y + M_13 y' = M_21 * x + M_22 * y + M_23

where (x, y) is the coordinates of the source pixel, and (x’, y’) is the coordinate for the destination of the warp.

Using the affine transform matrix M, we can take care of scaling, rotation, translation at the same time. However, since the increasing y direction is downward in an image, the rotational matrix is

```
[M_11, M_12] = [ cos(theta), sin(theta)]
[M_21, M_22] [-sin(theta), cos(theta)]
```

which is different from the rotational matrix for the Cartesian system

```
[M_11, M_12] = [ cos(theta), -sin(theta)]
[M_21, M_22] [ sin(theta), cos(theta)]
```

An easy way to remember this is, a point at (x, y) = (1, 1) will be rotated 45 degrees to (1.4, 0) on the x-axis, not y-axis, as it would be in the Cartesian system.