We propose, in a Ramsey interferometer, to cool the cavity field to its ground state, starting from a thermal distribution by a dispersive atom-field coupling followed by an atomic postselection. We also analyze the effect of the cavity and atomic losses. The proposed experiment can be realized with realistic parameters with high fidelity.