Recent advantages in the depth from defocus technique for the size and location determination of particles in dispersed two-phase flows have enabled the technique to detect and analyze spherical particle images in flow systems with high number concentrations. In the present study, the use of convolutional neural networks for this task will be explored, with comparisons to the conventional analyses in terms of accuracy, tolerable concentration limits and computational speed. This approach requires a large teaching dataset of images, which is only practical and feasible if the dataset can be synthetically generated. Thus, the first development to be presented is an image generation procedure for out-of-focus neighboring spherical particles resulting in a known blurred image overlap. This image generation procedure is validated using laboratory images of known particle size distribution, position and image overlap, before creating a teaching dataset. The trained processing scheme is then applied to both synthetic datasets and to experimental data. The synthetic datasets allow limits of image overlap and tolerable volume concentration limits of the technique to be evaluated as a function of particle size distribution.(https://github.com/xu200911/Generate-overlapping-out-of-focus-particles)