freground detection by GMM in matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi every body. I obtain foreground objects from my video, but the foreground detected have extra parts like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151828/image.png)
How I can create a foreground without this point or how I can remove them? my code is:
D = dir([FilePath, '\*.jpg']);
Num = length(D(not([D.isdir])));
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 20,'LearningRate',0.005,'MinimumBackgroundRatio',0.5,...
'InitialVariance', ((30)*(30)));
array=struct2cell(D(not([D.isdir])));
array_names=array(1,:);
for i=1:Num
CurrentImage = imread(strcat(FilePath,'\',array_names{i}));
fgMask = step(detector, CurrentImage);
imwrite(fgMask,strcat(OutputFile,'\',int2str(i),'.png'),'png');
end
댓글 수: 0
답변 (1개)
Dima Lisin
2015년 7월 7일
In general, you can use morphological operations, such as imopen to remove noise, and imclose to fill in small gaps.
In this particular case, the extra part seems to be caused by a shadow. You can try converting your frames to YCbCr color space using rgb2ycbcr, and only use the Cb and Cr channels for the foreground detector. This will get rid of shadows, but it will also remove any objects that are grey.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!