Filter löschen
Filter löschen

How do I use cross correlation to detect the Position of a particle in a 130x296x3 double struct (3 frames)

3 Ansichten (letzte 30 Tage)
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))

Akzeptierte Antwort

Image Analyst
Image Analyst am 27 Mär. 2022
See my normalized cross correlation demo. Adapt as needed.
  2 Kommentare
Gucci
Gucci am 29 Mär. 2022
Bearbeitet: Gucci am 29 Mär. 2022
@Image Analyst can you take look at the 3 images I uploaded on the post, I have tried to modify the normxcorr2 example code but I do not know how to implement it for all 3 images in my stack.
i need to track the displacement of the particle on each and compare to the previous one
can view each one using:
imagesc(ims(:,:,1));
imagesc(ims(:,:,2));
imagesc(ims(:,:,3));
Image Analyst
Image Analyst am 29 Mär. 2022
%============================================================================================================================================
% 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)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by