Compression theory for inhomogeneous systems