Freeform optics generating specific irradiance distributions have been used in various applications for some time now. While most freeform optics design algorithms assume point sources or perfectly collimated light, the search for algorithms for non-idealized light sources with finite spatial as well as angular extent is still ongoing. In this work, such an approach is presented where the resulting irradiance distribution of a freeform optical surface is calculated as a superposition of pinhole images generated by points on the optical surface. To compute the required arrangement of the pinhole images for a prescribed irradiance pattern, the expectation maximization algorithm from statistics is applied. The result is then combined with a ray-targeting approach for finding the shape of the corresponding freeform optical surface. At its current state, the approach is applicable to Gaussian input irradiances, single-sided freeform optics and for the paraxial case. An example freeform optical surface for laser material processing is shown and discussed demonstrating the performance and the limitations of the presented approach.