
i'd say you need to calculate the region each image takes, and calculate if image A overlaps image B (x,y coordinates etc.) It's easy for regular shaped images, like square, circule etc, but for irregular shaped images, you need to defined the points (on the image) that matters.

maybe there's a better way...