1. A method comprising the steps of: (i) receiving one or more input images; (ii) for each input image, specifying an initial offset map comprising a mapping of image elements from the input image onto an initialized output image; (iii) specifying a joint probability distribution on the output image, the input images and the offset maps; (iv) optimizing the joint probability distribution to find a learnt output image and offset maps, the learnt output image comprising learnt repeated-structure elements having variable shape, size and appearance; and (v) outputting the learnt output image and offset maps.