Pyramid blending query

Hi,

I am trying to stitch together multiple images together to create a composite high resolution image.

I am successfully able to do the following:

Find keypoints using SIFT Calculate Homography matrix Warp the image and place it on canvas at correct position warp the base image and place it correctly

However, when I try to do pyramid blending, it fails because the dimensions of the warped image and base image are not same. I tried to add padding to the base image but it fails every time. The reason is that the warp image has negative co-ordinates so I am unable to calculate its dimensions perfectly (or so I suspect)

There should be a simple fix for this, something really obvious that I am missing. This is a problem that was probably solved before I was born.

Can someone tell me in pseudo code or english what should be my plan of action to resolve this? I just want to pyramid blend them

thanks