I have a set of satellite image tiles from Bing Maps (info here). The tiles' names specify tile coordinates within the tile system and zoom, e.g.
An example set of tiles:
['156608-142775-18.jpg', '156608-142776-18.jpg', '156607-142777-18.jpg', '156608-142772-18.jpg', '156607-142776-18.jpg', '156608-142777-18.jpg']
Here are the tiles visualized:
What I need to do is to merge all neighboring images into one image. So, in my example, I wish to merge the lower five tiles into one and output two images - the big merged image and the upper single tile which has no neighbors.
I am not sure how to achieve this. It seems to me there should be a simple solution to this that I cannot figure out.
I will use the same code for merging a large number of tiles so I want to avoid solutions that use a lot of memory or take long time. I work in Python. I don't need the actual code, just an idea how to do this.