How can I force imregister to use the parameter 'InitialTransformation'?
3 views (last 30 days)
I am trying to register a stack of images to one fixed image, using imregister. I have 9 pictures and sometimes, the registration seem totally wrong. I use the following code:
tformEstimate = imregcorr(img_1, img_2);
[optimizer, metric] = imregconfig('monomodal');
movingRegistered = imregister(img_2, img_1, 'affine', optimizer, metric,'InitialTransformation',tformEstimate);
Some of the images totally flip, which is weird, since the images are almost the same. I notice if I do not use the transformation matrix, I get the result of the "flipped" image. So my thought is that maybe the transformation is not used. Is there any way to check for this?
I am doing this in order to perform a focus stacking after aligning the images.
Eric on 20 Apr 2015
Edited: Eric on 20 Apr 2015
One obvious problem: You have flipped the order of img_1 and img_2 in your two registration function calls. In your usage of imregcorr you are registering to img_2. In your usage of imgregister you are registering to img_1. So the initial estimate you are providing is completely wrong.
You might also try setting the 'DisplayOptimization' parameter of imregister to true. My guess is that the first objective function value is quite high. After correcting the problem I described in the last paragraph, the initial objective function value should be considerably lower. That would be an indication that the tformEstimate is being used.