Given an \$n\times m\$ matrix \$A\$ and two integers \$w,h\$, output a matrix of \$w\times h\$ called \$B\$, such that $$B_{i,j} = \int_{i-1}^i\mathbb dx\int_{j-1}^j A_{\left\lceil \frac xw\cdot n\right\rceil,\left\lceil \frac yh\cdot m\right\rceil}\mathbb dy\text{ (1-index),}$$ $$B_{i,j} = \int_i^{i+1}\mathbb dx\int_j^{j+1} A_{\left\lfloor \frac xw\cdot n\right\rfloor,\left\lfloor \frac yh\cdot m\right\rfloor}\mathbb dy\text{ (0-index),}$$ or "split a square into \$n\times m\$ smaller rectangles, fill each with the value given in \$A\$, then resplit into \$w\times h\$ one and get average of each small rectangle" (which is a simple image rescaling algorithm and that's why this title is used)
Shortest code in each language wins. You can assume reasonable input range, which may give good to few languages though.
Test cases:
$$ \begin{matrix}1&1&1\\ 1&0&1\\ 1&1&1\end{matrix}, (2,2) \rightarrow \begin{matrix}\frac 89&\frac 89\\ \frac 89&\frac 89\end{matrix}$$ $$ \begin{matrix}1&1&1\\ 1&0&1\\ 1&1&0\end{matrix}, (2,2) \rightarrow \begin{matrix}\frac 89&\frac 89\\ \frac 89&\frac 49\end{matrix}$$ $$ \begin{matrix}1&0\\0&1\end{matrix}, (3,3) \rightarrow \begin{matrix}1&\frac 12&0\\ \frac 12&\frac 12&\frac 12\\ 0&\frac 12&1\end{matrix}$$ $$ \begin{matrix}1&0\\0&1\end{matrix}, (3,2) \rightarrow \begin{matrix}1&\frac 12&0\\ 0&\frac 12&1\end{matrix}$$