Remove static background from video
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a video, attached to this question, whose background needs to be extracted. The background is composed of the static elements that are reflections from the glass surface. Ideally, only the mouse and the attached cables should be left after subtracting the background. I have tried global threshold but have not had much success with it and would appreciate any help!
0 Kommentare
Antworten (1)
Image Analyst
am 17 Mai 2023
Bearbeitet: Image Analyst
am 17 Mai 2023
I don't think it's too hard. First you have to process some frames where the mouse is moving and get a "mode" image, which is the pixel value that the pixel has most of the time (so you can't process frames where the mouse is in one position the majority of the time or the mode value will be the mouse and not the background). Or you can simply snap a photo before the mouse is introduced to the scene.
Once you have a mode/background image, then you can simply use imabsdiff to find out what pixels are different from the background and set those to zero.
mask = imabsdiff(thisFrame, backgroundImage) > 10;
% Get rid of small blobs smaller than 10 pixels.
mask = bwareaopen(mask, 10);
% Mask image by multiplying each channel by the mask.
maskedFrame = thisFrame .* cast(mask, 'like', thisFrame); % R2016b or later. Works for gray scale as well as RGB Color images.
Of course it would be better to avoid the problem in the first place. Use better, brighter lights. Put a polarizing sheet in front of the outside lamps and a rotating polarizer on the camera lens. Rotate the polarizer on the lens to minimize the reflections.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!