![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/942269/image.png)
How do I use cross correlation to detect the Position of a particle in a 130x296x3 double struct (3 frames)
조회 수: 3 (최근 30일)
이전 댓글 표시
I have to select a region where a particle is located and than track the movement of the particle across a number of frames. (3 frames in the uploaded file)
The tracking program needs to use cross correlation techniques, to find the centroid of the particle and its movement across all frames.
Finally, I need to obtain each centroid (x, and y, coordinates across all images).
I have attempted to do this but the only help I can find is for a stack of .tif images, however my images are of double format, as in the title.
I have also uploaded a file called my_mat_file.mat, and this contains a 130x296x3 struct called 'ims' which is the struct containing the 3 images. Please see if you can work with this... The way to open the first image is to load the mat file, and then use the command as follows:
imagesc(ims(:,:,1))
댓글 수: 0
채택된 답변
Image Analyst
2022년 3월 27일
See my normalized cross correlation demo. Adapt as needed.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/942269/image.png)
댓글 수: 2
Image Analyst
2022년 3월 29일
%============================================================================================================================================
% Initialization Steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 15;
markerSize = 40;
s = load('my_mat_file.mat')
rgbImage = s.ims;
subplot(2, 2, 1);
imshow(rgbImage);
impixelinfo
axis('on', 'image')
grayImage = rgb2gray(rgbImage);
subplot(2, 2, 2);
imhist(grayImage);
grid on;
mask = grayImage > 9000;
mask = bwareafilt(mask, 1); % Take largest blob only.
subplot(2, 2, 3:4);
imshow(mask);
impixelinfo
% Find weighted centroid
props = regionprops(mask,grayImage, 'WeightedCentroid')
xCentroid = props.WeightedCentroid(1);
yCentroid = props.WeightedCentroid(2);
hold on;
plot(xCentroid, yCentroid, 'r+', 'LineWidth', 2, 'MarkerSize', markerSize)
subplot(2, 2, 1);
hold on;
plot(xCentroid, yCentroid, 'r+', 'LineWidth', 2, 'MarkerSize', markerSize)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/945324/image.png)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!