How can I register (merge) two images using homography matrix?

14 views (last 30 days)
I'm working on registering (merging) two images from different two cameras. For that I've done...
  1. calibrate each camera alone to get points. (The images for checkerboard, and cameras are above each other).
  2. By using the points, I've calculated the homography matrix.
x = up(1,:); y = up(2,:); xd = down(1,:); yd = down(2,:);
npoints = size(up,2);
A = zeros(2*npoints,9);
for i = 1:npoints
A(2*i-1,:) = [x(i), y(i), 1, 0, 0, 0, -x(i)*xd(i), -xd(i)*y(i), -xd(i)];
A(2*i,:) = [0, 0, 0, x(i), y(i), 1, -x(i)*yd(i), -yd(i)*y(i), -yd(i)];
end
[u,s,v] = svd(A);
h = v(:,9);
H = reshape(h,3,3);
H = H';
And I've checked the homography matrix by sum(sum(H.^2,2),1) (which is equal to 1).
The problem is the merging did not work well. What shall I do?
  3 Comments
Asma Alharbi
Asma Alharbi on 22 Jan 2018
Edited: Asma Alharbi on 22 Jan 2018
Thank you for your response, I'm sorry but, Why shall I do pre-normalization? for merging, I calculate the corresponding x and y for up image using homography matrix then I used the following line for merging
%(c,d) is the corresponding coordinate of (a,b) at up image
Nimg(a,b,:) = 0.5*up(a,b,:)+0.5*down(c,d,:);
I had tested this one before to merge images, and it was working well. The problem now is the two images did not match well :(
Matt J
Matt J on 18 Jun 2021
Mouaz Alsamman 's comment moved here:
have you finished this, I'm currently doing the same thing but stock on how to merge the two images.

Sign in to comment.

Answers (1)

Matt J
Matt J on 19 Jun 2021
Edited: Matt J on 19 Jun 2021
I'd recommend using fitgeotrans() rather than an unnormalized DLT approach.

Community Treasure Hunt

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

Start Hunting!