We describe a simple method of obtaining optical sectioning in a conventional wide-field microscope by projecting a single-spatial-frequency grid pattern onto the object. Images taken at three spatial positions of the grid are processed in real time to produce optically sectioned images that are substantially similar to those obtained with confocal microscopes.