We present an automatization of Barnsley's manual algorithm for the solution of the inverse problem of iterated function systems (IFSs). The problem is to retrieve the number of mappings and the parameters of an IFS from a digital binary image approximating the attractor induced by the IFS. M.F. Barnsley et al. described a way to solve manually the inverse problem by identifying the fragments of which the collage is composed, and then computing the parameters of the mappings (Barnsley et al., Proc. Nat. Acad. Sci. USA, vol.83, p.1975-7, 1986; Barnsley, "Fractals Everywhere", Academic, 1988; Barnsley and Hurd, L., "Fractal Image Compression", A.K. Peters, 1992). The automatic algorithm searches through a finite set of points in the parameter space determining a set of affine mappings. The algorithm uses the collage theorem and the Hausdorff metric. The inverse problem of IFSs is related to the image coding of binary images. If the number of mappings and the parameters of an IFS, with not too many mappings, could be obtained from a binary image, then this would give an efficient representation of the image. It is shown that the inverse problem solved by the automatic algorithm has a solution and some experiments show that the automatic algorithm is able to retrieve an IFS, including the number of mappings, from a digital binary image approximating the attractor induced by the IFS.