Apply transform on an image at lower resolution onto that of higher resolution

11 views (last 30 days)
Hello, I am performing a transformation for video stabilization on frames at 0.125 of the original size. I would now like to infer the geometric transform back onto the original image.
for i = 1: 10
% Estimate transform from frame A to frame B, and fit as an s-R-t
H = cvexEstStabilizationTform(imgA_small,imgB_small);
HsRt = cvexTformToSRT(H);
Hcumulative = HsRt * Hcumulative;
imgB_small_transform = imwarp(imgB_small,affine2d(Hcumulative),'OutputView',imref2d(size(imgB_small)));
% img_B_original_size = ??
end
Any ideas how to acheive this please? Many thanks,

Accepted Answer

Alex Taylor
Alex Taylor on 17 Jun 2013
Edited: Alex Taylor on 17 Jun 2013
You have an estimate for rotation, scale, and translation. Ideally, the rotation and scale estimates that you obtain at lower scale are invariant to the fact that you have pre-scaled your images (this won't be strictly true in reality because you will lose information in downsampling that your features may be sensitive to). If your registration estimate indicates a scale difference of 1.2 and a rotation of 10 degrees, this is independent of whether you have pre-scaled your images as long as both images are at the same scale.
The translation component of your SRT transformation is relative to your downsampled images. You can see this immediately if you think about it: a translation in pixels of (-2,5) in your downsampled images is not the same amount of translation (in physical units) as (-2,5) pixels at full scale.
To solve your problem, you will need to re-scale your translation estimate in HsRt(3,1:2) by a factor of 8x to account for your initial pre-scaling.

More Answers (1)

Matt J
Matt J on 16 Jun 2013
Edited: Matt J on 16 Jun 2013
There are dozens of image registration files on the File Exchange
I don't know if all of them require the images to be at the same resolution, but you can always imsize() the high-resolution image down to the same resolution as the low-resolution image, if needed. It couldn't matter that much for the low parameter affine registration that you're trying to do.
  15 Comments
Matt J
Matt J on 18 Jun 2013
When I answered yesterday, I didn't notice Matt J's comments, which are spot on. Ashvin, try simply upscaling just the translation parameters in Hcummulative. That should work.
Earlier in this string of comments, Ashvin showed the following code. It should have had the effect of scaling the translation parameters, but apparently that didn't help. So, I am puzzled...
Hdown = [ 256/2048 0 0; 0 256/2048 0; 0 0 1];
Hup = [ 2048/256 0 0; 0 2048/256 0; 0 0 1];
Hcumulative = Hup * HsRt * Hcumulative * Hdown;
Nitin
Nitin on 21 Jun 2013
Many thanks to everyone for your time and input, I have learned a lot from all your suggestions and input.
Best,

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!