A device for capturing images where the incident light passes through a modulator that adjusts to provide a selected image. Imagewise light is received in a sensor which is in communication with a processor that implements an optimization algorithm. The processor is in communication with the modulator and controls functioning of the modulator to optimize and to obtain the selected image.