4. An $m \times n(m<n)$ square grid is divided into $m n$ unit squares. $N$ of these squares are initially colored black, and the rest are colored according to the following rule: if an empty square has at least two black neighbors (i.e., squares sharing a common edge), then it is colored black. Find the minimum value of $N$ such that all squares are black after a finite number of operations.
4. Label the rows as $1,2, \cdots, m$, and the columns as 1, $2, \cdots, n$. Denote the cell at the intersection of the $i$-th row and the $j$-th column as $(i, j)$, where $i \in\{1,2, \cdots, m\}, j \in\{1,2, \cdots, n\}$.

If $m=n$, then the table is an $m \times m$ square grid. By coloring the cells on one diagonal black, all cells can be turned black after a finite number of operations.

If $m<n$, the table can be divided into an $m \times m$ square grid and an $m \times(n-m)$ rectangular grid. In this case, the coloring method for the $m \times m$ square grid is the same as when $m=n$. The $m \times(n-m)$ rectangular grid is then discussed based on the parity of $n-m$.
(1) $n-m$ is odd.
Color the cells $(m, m+2 k-1)(k=1,2, \cdots, \left.\frac{n-m+1}{2}\right)$ black, and thus, all cells in the $m \times(n-m)$ grid can be turned black.
Therefore, $N=m+\frac{n-m+1}{2}=\frac{n+m+1}{2}$.
(2) $n-m$ is even.

Color the cells $(m, m+2 k)\left(k=1,2, \cdots, \frac{n-m}{2}\right)$ black, and thus, all cells in the $m \times(n-m)$ grid can be turned black.
Therefore, $N=m+\frac{n-m}{2}=\frac{n+m}{2}$.
Below is the proof: $N \geqslant\left\lfloor\frac{n+m+1}{2}\right\rfloor$.
A grid edge is called "good" if and only if it is the edge of exactly one black cell.

After all operations, all good edges are the edges of the original rectangle's boundary units, i.e., there are $2(m+n)$ good edges in the end.

If each operation colors a cell with $k(k \geqslant 2)$ good edges black, then it becomes $4-k$ good edges. Since $4-k \leqslant k$, the number of good edges does not increase. Therefore, if initially $N$ cells are colored black, the number of good edges is at most $4N$.
Thus, $4 N \geqslant 2(m+n) \Rightarrow N \geqslant \frac{m+n}{2}$.
Since $N$ is a positive integer, therefore, $N \geqslant\left\lfloor\frac{n+m+1}{2}\right\rfloor$.