estimate motion with opencv:contrib:reg class

asked 2016-07-11 09:40:14 -0600

asa gravatar image

Hi, I am estimating Affine motion between two images using the opencv::contirb::reg class. There are some issues I am facing.

  1. The images have to of the same size. The calculate() function inside the "mappergradaffine" class has a CV_DbgAssert(img1.size() == image2.size()); statement.
  2. The inversewarp() function inside the mapaffine class uses the OpenCV function remap().

Now for my purpose even the bordering areas of the image are important. But BORDER_TRANSPARENT is used in remap() which means pixels that cannot be interpolated will not be touched. So after warping I get artifacts along the image borders

I tried this workaround:

I take a slightly larger reference image and a smaller current image. I use the matchTemplate() function to find the best matching part from the reference image to the current image. Due to time constraint, I resize both the images to 1/16 size. Then I get the reference image same size as the current image and pass them to mapper class. I estimate affine motion between them and then use the affine matrix to warp the larger golden image. Now, this seems to work, but sometimes the matchTemplate()'s output isn't actually the part that should match with the current image. Also I am wondering as I am estimating affine motion between two slightly smaller images and then applying this affine motion to a slightly larger image, is the affine motion matrix correct for the larger image? (the larger reference image has roughly 300px more on all sides )

Can anyone suggest any good ideas?

Thanks

edit retag flag offensive close merge delete