Hardness in water is determined by the mineral content, specifically the amount of calcium and magnesium salts. Salts are formed when calcium and magnesium combine with bicarbonates, sulfates, chlorides, and nitrates.
The standard measurement of hardness in water is “grains per gallon,” with a grain representing 17.1 parts per million. Grains per gallon is usually reported “as calcium carbonate” (CaCO3) to facilitate comparison with other constituents of the water.
There are a variety of definitions of where “hard” water begins, but there is general agreement that water of 7 grains per gallon or more is hard enough that things would be improved by a water softener.
The standard treatment for hardness is a water softener. It can treat up to about 100 grains per gallon of hardness, although it's less effective when a large amount of sodium is present.
Reverse osmosis also removes hardness, but RO membranes are susceptible to scale. Municipalities use a process called “lime softening” which lowers but won't remove hardness completely. Other alternatives to conventional softening include sequestering with polyphosphates and electronic- or media-based treatments that do not remove hardness but condition it to be less objectionable.
Photo Source: WikiMedia, author: Hustvedt
(whole house & well units)