After registering two images in MATLAB (R2010a) (Image1, and Image2), I cannot seem to figure out how to get the translation correct. The algorithm has been tested and works with other programs. Here are some relevant snippets.
TForm = maketform('affine', Transform);
info = imfinfo('Image1.bmp');
Reg = imtransform(Image1, TForm,...
'XData', [1 (size(Image1,2)+Transform(3,1))],...
'YData', [1 (size(Image1,1)+Transform(3,2))],...
'FillValues', 255);
figure('Name', 'Reg'),...
imshow(Reg, 'InitialMagnification', 250);
imwrite(Reg, 'Reg.bmp', 'bmp');
hold on
H = imshow(Image2, gray(256));
set(H, 'AlphaData', 0.6)
This does not happen when I register Image1 to Image1, only when I try registering Image1 to Image2 (or the other way around). I have the same code made in C which seems to work fine. I believe it has something to do with my imtransform function.
Well, I believe it has to do something with the way the transformation is being applied. I did a direct registration with Image1 to Image1 (rotated 15 degrees about the center of mass), and it does not do the correct transformation. The transformation output is:
Transform =
0.9676 -0.2557 0
0.2596 0.9694 0
32.7217 -25.5110 1.0000
Which if I input this into an image registration program, it works just fine. Here is an example image I did just now,

A = Original Image, B = Rotated Original Image, C = Original Image Transformed.
Again the transformation is correct (tested using FMRIB’s-FLIRT registration software). MATLAB must be doing something different when applying it to the image.
The rotation matrix has the signs reversed.