Superimpose two images on top of each other.
4 次查看(过去 30 天)
显示 更早的评论
Hi, I am quite new to MATLAB and not very familiar with how imregtform, imwarp, and whether I should have used "affine" or "similarity/rigid" instead to achieve my goal.
I am trying to superimpose my movingRegistered image directly on top of my fixed image, but this is the outcome that I get :![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/667530/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/667530/image.jpeg)
I can't get my movingRegistered image to translate directly to the top of my fixed image.
Would switching my approach from intensity-based registration to control point registration/feature detection and matching be the better approach?
This is my code that I am currently using:
function myfunc()
clear;
clc;
cla;
close all
fixed = image_resizing("test1.1.JPG");
moving = image_resizing("test2.1.JPG");
fixed = rgb2gray(fixed);
moving = rgb2gray(moving);
fixed = imresize(fixed,0.6, 'AntiAliasing', true);
moving = imresize(moving, 0.6, 'AntiAliasing',true);
[optimizer, metric] = imregconfig('monomodal');
optimizer.MinimumStepLength = 5e-6;
optimizer.MaximumIterations = 300;
tform = imregtform(moving, fixed, 'affine', optimizer, metric,'DisplayOptimization',false);
movingRegistered = imwarp(moving,tform,'OutputView',imref2d(size(fixed)));
imshowpair(fixed, movingRegistered,'Scaling','joint')
end
These are my two images that I would be using :
&![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/667540/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/667535/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/667540/image.jpeg)
Thank you so much for your help!
1 个评论
Walter Roberson
2021-7-1
In some recent work I was doing, I found that using Phase Correlation worked much better than any of the other ones I tested.
回答(1 个)
Bjorn Gustavsson
2021-7-1
If your images are of equal size you can put them into different RGB-layers. Something like this:
merged(:,:,3) = fixed;
merged(:,:,1) = movingRegistered;
That should give you the fixed image as blue, and the movingRegistered as red. You might need to check the data-types (if double you'll need to normalize the merged to 0-1).
HTH
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!