Matlab implay tracking question

조회 수: 3 (최근 30일)
D
D 2011년 7월 5일
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
Walter Roberson
Walter Roberson 2011년 12월 8일
There is no such thing as an if loop.

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by