Skip to content Skip to sidebar Skip to footer

Opencv And Python -- How To Superimpose Images By Specifying Coordinates?

In short, my question is how do I put an image on top of another by specifying specific coordinates for the added image? I would need to extend the 'canvas' of the base image as ne

Solution 1:

Edit: I have now turned the answer linked below into a Python module, which you can now grab from GitHub here.


I answered this question a few weeks ago. The answer should contain everything needed to accomplish what you're after; the only thing I don't discuss there is alpha blending or other techniques to blend the borders of the images together as you would with a panorama or similar.

In order to not crop the warped photo you need to calculate the needed padding beforehand because the image warp itself could reference negative indices, in which case it won't draw them...so you need to calculate the warp locations first, pad your image enough to account for those indices outside your image bounds, and then modify your warp matrix to add those translations in so they get warped to positive values.

This allows you to create an image like this:

Blended, warped, padded image

Image from Oxford's VGG.

Post a Comment for "Opencv And Python -- How To Superimpose Images By Specifying Coordinates?"