Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to do an automated detection and tracking program to track zebrafish

ID: 3824995 • Letter: I

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 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

Explanation / Answer

BW2 = bwareaopen(BW,P) removes all connected components (objects) that have fewer than P pixels from the binary image BW, producing another binary image, BW2. The default connectivity is 8 for two dimensions, 26 for three dimensions, and conndef(ndims(BW), 'maximal') for higher dimensions. This operation is known as an area opening.

stackbw2 creates new image that remove all the connected component that have fewer than 1000 pixels for input image stackbw.

code is correct . copy the code in matlab file using .m extension and run the code.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote