Quantum mechanics
Quantum mechanics is based on the knowledge that a photon of a certain frequency means a photon of a certain amount of energy. Besides that relationship, a specific kind of atom can only give off certain frequencies of radiation, so it can also only give off photons that have certain amounts of energy.