Optical field sampling for imaging and optical testing