How to find the displacement in the vertical and horizontal directions( delta x and delta y) and find the angular displacement(ɸ) for image correlation.

2 Ansichten (letzte 30 Tage)
As we have found the correlation between two images. And also found the maximum point of correlation..
But dont know how to find the displacement in the vertical and horizontal directions( delta x and delta y)
And find the angular displacement(ɸ)? If any knows, please let me know. Thanks in advance.
The program is as per below...
Img1 = imread('C:\Users\DELL\Desktop\Natures\Nature1.jpg');
Img2 = imread('C:\Users\DELL\Desktop\Natures\Nature2.jpg');
N = 500; range = 1:N;
da = [0 20];
db = [30 30];
dc = [0 20];
dd = [30 30];
A=Img1(da(1) + range, da(2) + range);
B=Img1(db(1) + range, db(2) + range);
C=Img2(dc(1) + range, dc(2) + range);
D=Img2(dd(1) + range, dd(2) + range);
X = normxcorr2(A, B);
m = max(X(:));
[i,j] = find(X == m);
Y = normxcorr2(C, D);
m = max(Y(:));
[k,l] = find(Y == m);
R = zeros(2*N, 2*N);
R(N + range, N + range) = B;
R(i + range, j + range) = A;
R(N + range, N + range) = D;
R(k + range, l + range) = C;
figure
subplot(2,2,1), imagesc(A)
subplot(2,2,2), imagesc(B)
subplot(2,2,3), imagesc(X)
rectangle('Position', [j-1 i-1 2 2]), line([N j], [N i])
subplot(2,2,4), imagesc(R);
subplot(2,2,1), imagesc(C)
subplot(2,2,2), imagesc(D)
subplot(2,2,3), imagesc(Y)
rectangle('Position', [l-1 k-1 2 2]), line([N l], [N k])
subplot(2,2,4), imagesc(S);
delta_orig1 = da - db
%--> [30 10]
delta_recovered = [i - N, j - N]
%--> [30 10]
delta_orig2 = dc - dd
%--> [30 10]
delta_recovered = [k - N, l - N]
%--> [30 10]
Output:

Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by