It took me a few attempts to get all the details correct on how to store the images and assemble them properly. I eventually did it with a reasonable set of basic operations. I know it's not efficient -- I could definitely shorten the loops by using the "matches" object more efficently. But I'm sick of looking at it now.