% load background image
directory = '
/group/project/VISION/web/AV2/DATA2/frame';
data = [ directory, 'bg' , '.jpg'];
bgim =
imread(data, '
jpeg'
);
%import image
%magic numbers
threshold = 13;
opening = 5;
connopening = 200;
im = latest_im
(directory,
i);
binim = subim > threshold;
binim = binim(:,:,1) | binim(:,:,2) | binim(:,:,3);
erodedim = bwmorph(binim,'open', opening);
erodedim = bwmorph(binim,'close', opening);
erodedim = bwareaopen(erodedim,connopening);
labeledim = bwlabel(erodedim, 8);
% bwim = im2bw(subim, threshold);
imagesc(labeledim);
end