Barium is a contrast agent used in X-rays of the alimentary canal (digestive tract) to visualize the esophagus, stomach, and intestines. The patient drinks barium sulfate, which coats the digestive lining and appears white on X-rays. It is not used for blood grouping or brain X-rays.