We propose that the X-ray emission from radio-quiet active galactic nuclei and galactic black holes is due to Comptonization of soft thermal photons emitted by the underlying accretion disk in localized structures (blobs). The power per unit area produced by the blobs, impinging on the disk, can easily dominate the radiation internally produced by the disk. In this case the electron temperature and the high-energy spectrum can be determined in a similar way to that used in the previously studied homogeneous model (Haardt & Maraschi 1991). However, in the present model, (a) the emitted spectrum is largely independent of the fraction of gravitational power dissipated in the blobs; (b) the X-ray spectrum can be harder depending on a form factor of the blobs; (c) the UV (or soft X-ray for galactic objects) luminosity that is not intercepted by the blobs can be larger than the X-ray luminosity. In the framework of a simplified accretion disk alpha-OMEGA dynamo model, we make order-of-magnitude estimates of the number of active blobs, their size, their luminosity, and hence their compactness, finding values in agreement with what is observed. The expected UV to X-ray spectra and correlations of X-ray and UV light curves are discussed.