How to use image background subtraction in video
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kong
am 12 Mär. 2020
Bearbeitet: Kong
am 19 Mär. 2020
I want to background subtraction in the video.
The problem is that the first frame of some videos is not empty. I mean, there is a person in the first frame of video.
So when I use background subtraction, the result is not as good as below picture.
Do you have a great idea to solve it?
I think that I can use background image.
I am using this dataset http://www.wisdom.weizmann.ac.il/~vision/SpaceTimeActions.html
(Bend dataset)

I want to get this kind result. (the dataset is different)
(Side dataset)

clear all
close all
%// read the video:
reader = VideoReader('shahar_bend.avi');
vid = {};
while hasFrame(reader)
vid{end+1} = im2single(readFrame(reader));
end
%// simple background estimation using mean:
bg = mean( cat(4, vid{:}), 4);
%// estimate foreground as deviation from estimated background:
fIdx = 40; %// do it for frame 43
fg1 = sum( abs( vid{fIdx} - bg ), 3 ) > 0.25;
fg2 = imresize(fg1, 0.5);
figure;
subplot(141); imshow( bg );
subplot(142); imshow( vid{fIdx} );
subplot(143); imshow( fg2 );
0 Kommentare
Akzeptierte Antwort
Raynier Suresh
am 19 Mär. 2020
To do background subtraction but without knowing the background you could try image segmentation to remove the background. Many different image segmentation algorithms are available in MATLAB.
For Image Segmentation in MATLAB you could refer this link :
The “vision.ForegroundDetector” might help you to get the foreground object using the “Gaussian Mixture Models” .
For “vision.ForegroundDetector” in MATLAB you could refer this link:
Referring to the following links might be helpful:
Image Segmentation using K-Means Clustering:
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Preview and Device Configuration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!