speckle parren analysis and displacement measurement between every two concecutive frame
8 ビュー (過去 30 日間)
古いコメントを表示
I have a series of frames containing speckle patterns for which I need to calculate the displacement. I require each subsequent image to be compared with the previous image to determine displacement. In other words, I need to calculate the displacement between every two consecutive images. Can anybody assist me with this issue?
1 件のコメント
Manikanta Aditya
2024 年 2 月 26 日
Try checking the following reference about 'imregdemons' to know about estimating displacement between images:
回答 (1 件)
Rishi
2024 年 2 月 27 日
Hi Parastoo,
I understand that you want to know how to find the displacement between two consecutive frames.
You can find the displacement by using cross-corelation. This can be achieved using the 'normxcorr2' function. This function calculates the normalized cross-correlation of two matrices and returns a matrix containing correlation coefficients.
Here is a sample code for the same. You can modify it and use it for your own case.
num_images = 10; % Update this with the actual number of images
displacements = zeros(num_images - 1, 2);
% Loop over each pair of consecutive images
for i = 1:(num_images - 1)
img1 = imread(sprintf('frame%d.png', i));
img2 = imread(sprintf('frame%d.png', i + 1));
% Convert images to grayscale if they are not already
if size(img1, 3) == 3
img1 = rgb2gray(img1);
end
if size(img2, 3) == 3
img2 = rgb2gray(img2);
end
% Perform cross-correlation
c = normxcorr2(img1, img2);
% Find the peak in cross-correlation
[max_c, imax] = max(abs(c(:)));
[ypeak, xpeak] = ind2sub(size(c), imax(1));
% Account for the padding that normxcorr2 adds
corr_offset = [(xpeak-size(img1,2)) (ypeak-size(img1,1))];
displacements(i, :) = corr_offset;
end
In the above code, displacement is the difference in the peak locations in the cross-correlation matrix 'c' from the center.
You can find more details about the 'normxcorr2' function from the below documentation:
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Oceanography and Hydrology についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!