Notation
I have assumed that “$2\times3$” means “$2$ rows and $3$ columns”. Is my assumption correct?
It depends on the context. In general I'd agree, but since the counts you quote doesn't include a separate handling of the $3\times2$ case, in this situation I'd rather assume that $2\times3$ is meant to cover both orientations, both two rows and three columns and two columns and three rows.
Total count
Can someone help me to find how many rectangles there are in the rectangular grid below?
If all you are interested in is the total number of non-square rectangles, then it doesn't matter how you write down each individual count. In fact, I'd not iterate over all possible shapes, but instead use a different approach.
For a grid of $m\times n$ tiles, there are $(m+1)\times(n+1)$ tile corners. If you consider each of them as a possible corner of a rectangle, and define each rectangle by two opposite corners, then you have a total of
$$\bigl((m+1)(n+1)\bigr)^2$$
possible combinations of two points. Obviously, that number is way too large, because we counted some things we shouldn't, and counted others more than once. So let's address those issues.
You don't want either dimension of such a rectangle to be zero. So if you picked the first point, then there are $m+n+1$ possible positions where that second point would be in the same row and/or the same column as the first. Subtract that and you are at
$$(m+1)(n+1)\bigl((m+1)(n+1)-(m+n+1)\bigr)=(m+1)(n+1)mn\;.$$
As Arthur pointed out in a comment, you can think of this as picking the second point from the $m\times n$ possible corner positions which you obtain by removing the “forbidden” row and column. At this point you have two points in distinct rows and columns, but nothing is sorted yet. So every possible rectangle is counted four times: any of its four corners might be the first point, with the opposite corner as the second point. So the number of rectangles is
$$\tfrac14(m+1)(n+1)mn\;.$$
Now you still have to get rid of those squares. How many are there? Let's look for a pattern. There are $m\times n$ squares of size $1$. There are $(m-1)\times(n-1)$ squares of size $2$, and so on. The maximal size such a square can have is the smaller of the dimensions of your tile grid. So there are
$$\sum_{i=1}^{\min(m,n)}(m+1-i)(n+1-i)$$
squares in total. Assuming $m\le n$ this simplifies to
$$\sum_{i=1}^{m}(m+1-i)(n+1-i)=\tfrac16 m(m+1)(3n-m+1)\;.$$
Now take the number of all rectangles, subtract all squares, and you are done. If you expand and then factor the result, you get a total count of
$$\tfrac1{12}m(m+1)(3n^2 + 2m - 3n - 2)=
\tfrac1{12}m(m+1)\bigl(3n(n-1) + 2(m-1)\bigr)\;.$$
For $m=n=3$ this indeed yields a count of $22$. For $m=5,n=7$ (remember to ensure $m\le n$) this gives a count of $335$ non-square rectangles. You can verify that count with a brute-force computation.
Bonus question
If you want to, it might be interesting to think about why that formula always results in an integer if $m,n$ are integers.
Either $m$ or $m+1$ is divisible by two, so their product is even. For the same reason, $n(n-1)$ is even, and since $2(m-1)$ is even, too, $\bigl(3n(n-1) + 2(m-1)\bigr)$ must be even. So the whole thing is the product of two even numbers, and therefore divisible by four.
Exactly one of $m,(m+1),(m-1)$ is divisible by three. In the first two cases, the whole product is obviously divisible by three. In the last case, $\bigl(3n(n-1) + 2(m-1)\bigr)$ is divisible by three since it's the sum of two integers which are divisible by three. As the whole thing is divisible by four and by three, it is divisible by twelve.
I think from your input you can simply calculate the position of each of the four vertex. It is going to be:
[x,y] , [x+l,y] , [x,y+w] , [x+l,y+w]
Then you sort this list of 4*cnt elements and remove duplicates and count the cardinality. I don't think you can have a closed formula because the domain of your function depends on how many grids you have:
vertex = $f(g_1,g_2,....,g_{cnt})$
where $g \in N^4$ (4 dimension arrays of natural numbers)
Best Answer
We will count $n\!\times\!3$ grids containing no $2\!\times\!2$ block of $1$s ("three-row square-free grids"):
If we encode the columns by integers using the entries as the digits of a binary number, then for three rows, we have three classes of columns: $A=\{0,1,2,4,5\}$, $B=\{3,6\}$ and $C=\{7\}$, with transfer matrix $M=\Big(\begin{smallmatrix}5&2&1\\5&1&0\\5&0&0\end{smallmatrix}\Big)$.
The number of three-row square-free grids is thus the sum of the entries in the vector $$(5,2,1)\,M^{n-1}.$$ The closed form is complex, involving roots of cubic polynomials.
The first few terms are $8, 57, 417, 3032, 22077, 160697, 1169792, 8515337, 61986457, 451223152$. This is A181246 in OEIS.
Alternatively, if we let $a(z)$, $b(z)$ and $c(z)$ be the (ordinary) generating functions for $n\!\times\!3$ square-free grids where the final column is in classes $A$, $B$ and $C$ respectively, and we let $g_3(z)$ be the OGF for all three-row square-free grids, then solving the equations $$\begin{array}{rcl}a(z) &=& 5 z + z\:\! (5 a(z) + 5 b(z) + 5 c(z))\\ b(z) &=& 2 z + z\:\! (2 a(z) + b(z))\\c(z) &=& z + z\:\! a(z)\\g_3(z)&=&a(z)+b(z)+c(z)\end{array}$$ gives $$g_3(z)\;=\;\frac{z\:\! (8 + 9 z - 5 z^2)}{1 - 6 z - 10 z^2 + 5 z^3}.$$
For four-row grids, five classes are required, with transfer matrix $\left( \begin{smallmatrix} 8 & 4 & 1 & 2 & 1 \\ 8 & 2 & 1 & 1 & 0 \\ 8 & 4 & 0 & 0 & 0 \\ 8 & 2 & 0 & 0 & 0 \\ 8 & 0 & 0 & 0 & 0 \end{smallmatrix} \right)$, giving generating function $\frac{8 z (2+7 z+z^2-8 z^3)}{1-10 z-54 z^2-16 z^3+64 z^4}$.
There are many numerical results in OEIS: three rows, four rows, five rows, six rows, seven rows, eight rows, and nine rows.