A smart phone or tablet includes laser diodes configured to be pulsed and generate near-infrared light between 700-2500 nanometers. Lenses direct the light to a sample. A detection system includes a photodiode array with pixels coupled to CMOS transistors, and is configured to receive light reflected from the sample, to be synchronized to the light from the laser diodes, and to perform a time-of-flight measurement of a time difference between light from the laser diodes and light reflected from the sample. The detection system is configured to convert light received while the laser diodes are off into a first signal, and light received while at least one laser diodes is on, which includes light reflected from the sample, into a second signal. The smart phone or tablet is configured to difference the first signal and the second signal and to generate a two-dimensional or three-dimensional image using the time-of-flight measurement.