How to extract the moving wavy foreground from video ?

1 回表示 (過去 30 日間)
Sumit Chaudhary
Sumit Chaudhary 2016 年 5 月 4 日
編集済み: Sumit Chaudhary 2016 年 5 月 4 日
I have extracted the foreground from video using vibe algorithm and then converted it binary video for further processing. In vibe algorithm, they use initial frames as background and detect foreground in subsequent frames. For me, initial frames are very important(lost during binary conversion via vibe). In vibe software, in initial frames wavy foreground is sometimes not completely detected enough though the wavy pattern is present completely. I was wondering, if there was another foreground extraction technique which do not lose initial frames. I have tried saving the frames in reverse order, so that data in initial frames is not lost but it didn't worked. Since this wavy front is moving to the left side, I Also tried subtracting current frame from initial frame to get the desired results. I am stuck at a point.The code that I am using is :
% Reading input .jpg files
for index = 1:104
if index == 1
back = strcat('250_00',num2str(index),'.jpg');
index
elseif 2<index<10
filename = strcat('250_00',num2str(index),'.jpg');
index
[im]=RemoveBackground(filename,back );
elseif 10<index<100
filename = strcat('250_0',num2str(index),'.jpg');
[im]=RemoveBackground(filename,back );
elseif 100<index<1000
filename = strcat('250_',num2str(index),'.jpg');
[im]=RemoveBackground(filename,back );
else
filename = strcat('out',num2str(index),'.jpg');
[im]=RemoveBackground(filename,back );
end
Function used :-
function [im]=RemoveBackground(I,Ib)
% Ib=background image
% I=input image
% im=background removed image
I1=rgb2gray(I);
Ib1=rgb2gray(Ib);
Id=imsubtract(Ib1,I1);
Id=Id;
Id=bwareaopen(Id,500,8);
Id=imfill(Id,'holes');
BW=Id;
Id=uint8(Id);
[r c]=size(Id);
for i=1:r
for j=1:c
if Id(i,j)==255
Id(i,j)=1;
end
end
end
im(:,:,1)=I(:,:,1).*Id;
im(:,:,2)=I(:,:,2).*Id;
im(:,:,3)=I(:,:,3).*Id;
I am getting this error when i run this code:
Error using rgb2gray>parse_inputs (line 81) MAP must be a m x 3 array.
Error in rgb2gray (line 35) X = parse_inputs(varargin{:});
Error in RemoveBackground (line 5) I1=rgb2gray(I);
Error in bc (line 10) [im]=RemoveBackground(filename,back ); end ORIGINAL IMAGE
<<
>> PROCESSED FRAME

回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by