4. Given real numbers $a, b$ satisfy
$$
|a-1|+\sqrt{(a-2)(b-2)^{2}}+\left|b^{2}+1\right|=a \text {. }
$$

Then $a^{b}=(\quad$.
(A) $\frac{1}{4}$
(B) $\frac{1}{2}$
(C) 1
(D) 2
4. C.

From the given, we know
$$
1=|a-1|-(a-1)+\sqrt{(a-2)(b-2)^{2}}+\left|b^{2}+1\right| \geqslant 1 \text {, }
$$

when $a=2, b=0$, the equality holds. Therefore, $a^{b}=1$.