Image Registration Issues - Why is imregister() flipping my moving image upside down?
9 views (last 30 days)
Show older comments
I'm a beginner in MATLAB, trying to align some images using imregister(). The images are of biological tissue sections. I am having some major issues aligning the images... the result from imregister() flips the image entirely upside down, when it shouldn't be.
Why would imregister() flip the moving image upside down like this? The resulting image is now even more mis-aligned to the fixed imaged than it was pre-registration. Also, the tissue sections to be aligned in the fixed and moving images are very similar to begin with so I'm not sure why imregister() would make such a false alignment.
Here is my very basic code:
fixed = imread('slice1.jpg');
moving = imread('slice2.jpg');
gfixed = rgb2gray(fixed);
gfixed2 = medfilt2(gfixed);
img1 = adapthisteq(gfixed2);
gmoving = rgb2gray(moving);
gmoving2 = medfilt2(gmoving);
img2 = adapthisteq(gmoving2);
[optimizer,metric]=imregconfig('monomodal');
optimizer.GradientMagnitudeTolerance = 1.00000e-04;
optimizer.MinimumStepLength = 3.00000e-04;
optimizer.MaximumStepLength = 6.25000e-02;
optimizer.MaximumIterations = 300;
optimizer.RelaxationFactor = 0.500000;
im_aligned = imregister(img2, img1,'rigid',optimizer,metric);
figure(1),imshowpair(img1,im_aligned); % shows im_aligned is entirely flipped upsite down with respect to fixed image
2 Comments
Answers (1)
Madhav Thakker
on 8 Sep 2020
Hi Ashlyn,
I understand that the moving image is flipped after registration. One reason for the flipping can be because of using rigid parameter when calling imregister(). The rigid transformation only supports translation and rotating. It is clear from the images that objects of interest are not of same size in the images. I made a few changes in your code and it seems to be performing better now.
fixed = imread('slice2.jpg');
moving = imread('slice3.jpg');
gfixed = rgb2gray(fixed);
gfixed2 = medfilt2(gfixed);
img1 = adapthisteq(gfixed2);
gmoving = rgb2gray(moving);
gmoving2 = medfilt2(gmoving);
img2 = adapthisteq(gmoving2);
[optimizer,metric]=imregconfig('multimodal');
optimizer.MaximumIterations = 300;
im_aligned = imregister(img2, img1,'similarity',optimizer,metric);
figure(1),imshowpair(img1,im_aligned); % shows im_aligned is entirely flipped upsite down with respect to fixed image
For more details, you can refer to https://www.mathworks.com/help/images/ref/imregister.html
Hope this helps.
0 Comments
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!