It is enough to consider what happens on one side, i.e. count the number of intervals. The number of rectangles will be the product of the numbers vertically and horizontally (consider the Cartesian product).
In the case that $m$ and $m'=\lceil\xi m\rceil$ are relative primes, there are $m+m'-1$ intervals, because there are $m+1$ and $m'+1$ bounds respectively, and the two extreme coincide.
When the pixel counts aren't relative primes, the bounds coincide periodically, $\gcd(m,m')+1$ times.
Hence, there are
$$(m+m'-\gcd(m,m'))(n+n'-\gcd(n,n'))$$ rectangles.
In the given example, $(8+15-1)^2=484$.