Lensless fluorescence imaging (LFI) is the imaging of fluorescence from cells or microspheres using an image sensor with no external lenses or filters. The simplicity of the hardware makes it well suited to replace fluorescence microscopes and flow cytometers in lab-on-a-chip applications, but the images captured by LFI are highly dependent on the distance between the sample and the sensor. This work demonstrates that not only can samples be accurately detected across a range of sample-sensor separations using LFI, but also that the separation can be accurately estimated based on the shape of fluorescence in the LFI image. First, a theoretical model that accurately predicts LFI images of microspheres is presented. Then, the experimental results are compared to the model and an image processing method for accurately predicting sample-sensor separation from LFI images is presented. Finally, LFI images of microspheres and cells passing through a microfluidic channel are presented.