A method for imaging a target, the method comprising: at a system having one or more processors and memory: activating an excitation light source to generate an excitation pulse to illuminate the target; receiving an ambient light intensity signal from an ambient light intensity sensor during a portion of the period in which the excitation light source is not activated; exposing an image sensor for a first exposure time for fluorescence light during the excitation pulse; receiving outputs from the image sensor; detecting a periodic frequency of the ambient light intensity; compensating for ambient light based on the ambient light intensity signal, wherein compensating for ambient light comprises: synthesizing or extracting, from one or more received ambient light intensity signals, a complete periodic cycle of ambient light intensity having the detected periodic frequency; extrapolating the ambient light intensity periodic cycle to a time period corresponding to the first exposure time; calculating a first accumulated ambient light value corresponding to an area under the curve of ambient light intensity during a second exposure time for background light; calculating a second accumulated ambient light value corresponding to an area under the curve of the ambient light intensity during the first exposure time; scaling the received image sensor output for the second exposure time and the received image sensor output for the first exposure time based on a ratio of the first and second accumulated ambient light values; and subtracting the scaled image sensor output for the second exposure time from the scaled image sensor output for the first exposure time to form the resultant image; and storing a resultant image in the memory. activating an excitation light source to generate an excitation pulse to illuminate the target; receiving an ambient light intensity signal from an ambient light intensity sensor during a portion of the period in which the excitation light source is not activated; exposing an image sensor for a first exposure time for fluorescence light during the excitation pulse; receiving outputs from the image sensor; detecting a periodic frequency of the ambient light intensity; compensating for ambient light based on the ambient light intensity signal, wherein compensating for ambient light comprises: synthesizing or extracting, from one or more received ambient light intensity signals, a complete periodic cycle of ambient light intensity having the detected periodic frequency; extrapolating the ambient light intensity periodic cycle to a time period corresponding to the first exposure time; calculating a first accumulated ambient light value corresponding to an area under the curve of ambient light intensity during a second exposure time for background light; calculating a second accumulated ambient light value corresponding to an area under the curve of the ambient light intensity during the first exposure time; scaling the received image sensor output for the second exposure time and the received image sensor output for the first exposure time based on a ratio of the first and second accumulated ambient light values; and subtracting the scaled image sensor output for the second exposure time from the scaled image sensor output for the first exposure time to form the resultant image; and storing a resultant image in the memory. synthesizing or extracting, from one or more received ambient light intensity signals, a complete periodic cycle of ambient light intensity having the detected periodic frequency; extrapolating the ambient light intensity periodic cycle to a time period corresponding to the first exposure time; calculating a first accumulated ambient light value corresponding to an area under the curve of ambient light intensity during a second exposure time for background light; calculating a second accumulated ambient light value corresponding to an area under the curve of the ambient light intensity during the first exposure time; scaling the received image sensor output for the second exposure time and the received image sensor output for the first exposure time based on a ratio of the first and second accumulated ambient light values; and subtracting the scaled image sensor output for the second exposure time from the scaled image sensor output for the first exposure time to form the resultant image; and storing a resultant image in the memory.