Theory of Nucleation Fields in Inhomogeneous Ferromagnets