Matlab implay tracking question
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I have modified the car tracking software below to track all blobs, or at least this is my goal. However, I am having trouble. Here is the loop I am working in, it will look familiar to some:
for k = 1 : nframes
singleFrame = read(bwStack, k);
% Convert to grayscale to do morphological processing.
I = rgb2gray(singleFrame);
% Remove dark objs.
noDarkValues = imextendedmax(I, threshValue);
% Remove lane markings and other non-disk shaped structures.
noSmallStructures = imopen(noDarkValues, sedisk);
% Remove small structures.
noSmallStructures = bwareaopen(noSmallStructures, 10);
noSmallStructures = bwlabeln(noSmallStructures);
% Get the area and centroid of each remaining object in the frame. The
% object with the largest area is the light-colored object. Create a copy
% of the original frame and tag the object by changing the centroid pixel
% value to red.
taggedObjs(:,:,:,k) = singleFrame;
stats = regionprops(noSmallStructures,'Centroid','Area','PixelIdxList','PixelList');
if ~isempty([stats.Area])
areaArray = [stats.Area];
[junk,idx] = max(areaArray);
c = stats(idx).Centroid;
c = floor(fliplr(c));
width = 2;
row = c(1)-width:c(1)+width;
col = c(2)-width:c(2)+width;
taggedObjs(row,col,1,k) = 255;
taggedObjs(row,col,2,k) = 0;
taggedObjs(row,col,3,k) = 0;
end
end
The last part (the if loop) is where I am having trouble. I need to replace the "finding the largest area and plot that centroid" with find all centroids over a certain threshold
if(stats(i).Area>10)
And then plot all of the centroids which make it past the threshold instead of having merely one centroid per frame. In addition, is there a easy way to add color labels to all of these objects?
1 commentaire
Réponses (0)
Voir également
Catégories
En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!