I am doing some research and need to track the displacement of nanoparticles in a video that I captured. I have started to write the code; however, I am stuck.
I need to find a way to label each particle and determine in the next frame where that particle moved to. I have calculated the centroid of each particle and written them to a table. I am not sure how to compare these centroid particles and track them across 50 frames. Particles tend to come and go as they go in and out of the focal plane.
Thanks.
Code:
clear all;
mov = aviread('50Mol_Simul.avi'); %Convert video to images
for m =1:length(mov)
[im,map] = frame2im(mov(m));
imwrite(im, ['im' num2str(m) '.jpg'],'jpg');
end
mov = mmreader('50Mol_Simul.avi');
implay('50Mol_Simul.avi');
nFrames = mov.NumberOfFrames
Width = mov.Width
Height = mov.Height
for k = 1 : nFrames
singleFrame = read(mov, k);
level = graythresh(singleFrame);
bw = im2bw(singleFrame, level);
% figure;
% imshow(bw);
bw = bwareaopen(bw, 3);
L = bwlabel (bw,8);
stats = regionprops(bw,'Centroid');
V = cat(1,stats.Centroid);
temp.ctrd = V;
temp.index = zeros(size(V,1),1);
a(k) = temp;
end
I am not sure how to attach the video file. If some one tells, I can upload that as well.

Réponses (1)

Jianan
Jianan le 12 Mai 2011

1 vote

I am not good at coding, but I used the codes below for my experimental images. It works very well. Hope it will be helpful for you too.

4 commentaires

Prasad Kalane
Prasad Kalane le 3 Nov 2013
Nice information, Thanks Jianan
TripleCaffeine
TripleCaffeine le 30 Nov 2017
link is now dead
Shweta Narayan
Shweta Narayan le 4 Juin 2019
Arash Beyrami
Arash Beyrami le 24 Jan 2020
Could you please explain more that how it works?

Connectez-vous pour commenter.

Question posée :

le 19 Avr 2011

Commenté :

le 24 Jan 2020

Community Treasure Hunt

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

Start Hunting!

Translated by