Question

I have a video that I am using background subtraction and motion segmentation on. The floor in the video is black, so when I get the silhouette the feet and parts of the legs are cut off. Is there a fix around this? This is what it looks like. enter image description here

enter image description here

This is the background image. This is a piece of my code....

clear all
close all
clc
% Read the video in the video object Mov
MM = mmreader('kassie_test_video.wmv');
% Read in all video frames.
Mov = read(MM);
% Get the number of frames.
FrameNum = MM.NumberOfFrames;
% load 'object_data.mat'
BackgroundImage = (Mov(:,:,:,98)); % background image
% set the sampling rate as well as the threshold for binary image.
downSamplingRate = MM.FrameRate;
%%
index = 1;
clear IM
clear Images
sf=10;ef=sf+30;
for ii =sf:ef

    % Extract next frame
    Im = im2double(Mov(:,:,:,ii));

    % Background subtraction
    Ib = rgb2gray(abs(im2double((Mov(:,:,:,ii)))-im2double(BackgroundImage)));
    % conversion to binary image.
    Thresh = graythresh(Ib);
    Ib = im2bw(Ib, Thresh);
    se = strel('square',1);
    Ib = imerode(Ib,se);    % Erode the image
    Ib = medfilt2(Ib);      % median filtering
    Ib = imfill(Ib,'holes');    % fill the holes in the image
    imshow(Ib,[])
end
Was it helpful?

Solution

there is a limit to what can be achieved in computer vision utilizing only pixel-processing without incorporating higher-level semantic information. it appears as if he only thing that makes you think the legs are missing is your high-level knowledge of how a body should look like. The real question here: is there any real information in the pixels? if it just so happen that the legs are exactly the same color as the background there's nothing much you can do unless you incorporate high level semantic information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top