Hello there!
Do you know if there is interaction between the X axis and the Y axis? If there is, you will need to do a LOT of iterations..... i.e. N iterations of Y for each iteration of X. This is not a simple chore. However, if there is no interaction between the two axes, the job is relatively simple.
I've attached a very general form "iteration engine", which I've adapted from a phase locked loop. On the diagram, you will see my arbitrary arrays which can be replaced by images. I think you can modify it in short order to do what you need to do.
Good luck!
Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705