  We develop a method to perform an untargeted Bayesian search for anisotropic
gravitational-wave backgrounds that can efficiently and accurately reconstruct
the background intensity map. Our method employs an analytic marginalization of
the posterior of the spherical-harmonic components of the intensity map,
without assuming the background possesses any specific angular structure. The
key idea is that the likelihood function of the spherical-harmonic components
is a multivariate Gaussian when the intensity map is expressed as a linear
combination of the spherical-harmonic components and the noise is stationary
and Gaussian. If a uniform and wide prior of these spherical-harmonic
components is prescribed, the marginalized posterior and the Bayes factor can
be well approximated by a high-dimensional Gaussian integral. The analytical
marginalization allows us to regard the spherical-harmonic components of the
intensity map of the background as free parameters, and to construct their
individual marginalized posterior distribution in a reasonable time, even
though many spherical-harmonic components are required. The marginalized
posteriors can, in turn, be used to accurately construct the intensity map of
the background. By applying our method to mock data, we show that we can
recover precisely the angular structures of various simulated anisotropic
backgrounds, without assuming prior knowledge of the relation between the
spherical-harmonic components predicted by a given model. Our method allows us
to bypass the time-consuming numerical sampling of a high-dimensional
posterior, leading to a more model-independent and untargeted Bayesian
measurement of the angular structures of the gravitational-wave background.
