Integrating cavities are being used for illumination in scanners. An integrating cavity is hollow, with entrance and exit holes, and a diffusely reflecting white interior. Light enters, undergoes multiple reflections to distribute the light uniformly, and exits toward the film or document. An arbitrarily shaped exit hole provides a uniform, diffuse light source of any desired shape, most commonly a line source. Integrating cavities also are being used as light collection systems, such as in laser scanners, where typically light enters a slit and exits a round hole, continuing to a photodetector. In this paper, integrating cavities are theoretically modelled by Mont Carlo ray tracing. This approach is very versatile, capable of modelling various types of cavity surfaces (diffuse, specular, refractive), arbitrary geometries, and arbitrary input light distributions. Results are presented for cavity efficiency, spatial uniformity and angular distribution of the exiting light. Complex cavity geometries from scanners in use are modelled. Theoretical results are compared with laboratory measurements.