is there a bug in imregcorr-function for transformtype "rigid" ?

9 views (last 30 days)
I have tried some examples where imregcorr does not give the wanted result for the transformtype "rigid" , for the same examples I obtain the correct result when using "similarity" .
Here is one example :
I1 = imread('...\cameraman.tif');
FIXED = im2double(I1);
MOVING = imrotate(I1,125);
fixedRefObj = imref2d(size(FIXED));
movingRefObj = imref2d(size(MOVING));
tform = imregcorr(MOVING,movingRefObj,FIXED,fixedRefObj,'transformtype','rigid','Window',true);
MOVINGREG.RegisteredImage = imwarp(MOVING, movingRefObj, tform, 'OutputView', fixedRefObj,'interp','cubic', 'SmoothEdges', true);
imshow(MOVINGREG.RegisteredImage) giving the following output image :
This is far away from the original cameraman image, which was rotated 125 degrees counterclockwise
  1 Comment
Eirik Kvernevik
Eirik Kvernevik on 28 Oct 2021
I have found problems for the "rigid" transformtype for a multiple og angles : a bunch of angles between 21 and 87 degrees , and a bunch between 133 and 239 degrees is what I have found so far.
there also seems to be a problem with the "similarity" type for 88, 89, 268 and 269 degrees . Would be interesting if anyone else have problems with this or if someone have a solution to this ?

Sign in to comment.

Answers (1)

Steve Eddins
Steve Eddins about 1 hour ago
As of R2024b, the function imregcorr uses a new algorithm called normalized gradient correlation. See my 16-Oct-2025 blog post for more information. The function can now register images successfully.
fixed_image = imread("cameraman.tif");
moving_image = imrotate(fixed_image, 125);
tiledlayout(1,2)
nexttile
imshow(fixed_image), title("fixed image")
nexttile
imshow(moving_image), title("moving image")
tform = imregcorr(moving_image, fixed_image)
tform =
simtform2d with properties: Dimensionality: 2 Scale: 1.0001 RotationAngle: 124.9967 Translation: [377.8203 84.5295] R: [2×2 double] A: [-0.5736 -0.8193 377.8203 0.8193 -0.5736 84.5295 0 0 1.0000]
[moving_image_reg,moving_reg_ref] = imwarp(moving_image, imref2d(size(moving_image)), tform);
clf
imshowpair(fixed_image,imref2d(size(fixed_image)),moving_image_reg,moving_reg_ref)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!