Projection of Hermitian operators onto eigenspaces of observables