Question: I am trying to do an automated detection and tracking program to track zebrafish in a video file using MATLAB. We are having trouble trying
I am trying to do an automated detection and tracking program to track zebrafish in a video file using MATLAB. We are having trouble trying to find the connected components and the centroids of the fish in each frame after frame number one. We have gotten the connected components and the centroids in frame one, but now we are just trying to get it in a loop to go through each frame. We understand the concept just not actually how to execute it. I have included the code for this section to find the connected components and centroids in frame 1.
Just to clarify, "stackbw2" is what we are using to perform morphological operations on and it is now in a logical. The code is below in bold in MATLAB. Thank you
implay(stackbw); % displays the video of each stacked binarized tiff image in sequence
stackbw2 = bwareaopen(stackbw, 1000); % area opening
CC = bwconncomp(stackbw2) % finds the number of connected components in each image
% Determine which is the largest component in the image and erase it
numPixels = cellfun(@numel,CC.PixelIdxList);
[biggest,idx] = max(numPixels);
stackbw2(CC.PixelIdxList{idx}) = 0; % sets largest image to black
implay(stackbw2) % plays video with just fish, no petri dish
% find the center of each fish in frame 1
centroid1 = regionprops(stackbw2,'Centroid');
% Concatenate structure array containing centroids into a single matrix
% (frame 1)
centroids1 = cat(1,centroid1.Centroid);
% Display graph of image with centroid locations (frame 1)
implay(stackbw2);
hold on
plot(centroids1(:,2),centroids1(:,3),'b*')
hold off
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
