An automated procedure for measuring the size and number of microscopic particles contaminating a fluid is described. The procedure, based on edge detection and region filling, exhibits substantially improved accuracy when compared to simple thresholding techniques, while being only slightly more complicated. The procedure is much less complex than model-based approaches and is shown to be more robust than simple threshold-based techniques in the presence of image blur caused by out-of-focus particles. A clever filling scheme is presented that efficiently segments particles from the background by first identifying pixels that are not particles. Results for two particle types and several focus conditions are given for comparison.