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 = ??
Any ideas how to acheive this please? Many thanks,
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.
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.