How to update a background model in motion detection

1 次查看(过去 30 天)
Hi I am implementing an equation for my abckground model. I have its mathematical form and i believed i implemented it on MTALAB but there seems to be a problem. Either there is some thing missing in my synatx so i was wondering if any one out there can ahve a lookl and correct mr or guide me. Basically what it does is the if equation get satisifes it fills 1on that location (1 in image pixel) else it put 0 in that location.This is my equation
imageGray-meanofIMage>3max(imageVariance,cameranoiseVariance)
if true
if(abs(imGray(row_loop,col_loop)-state.meanIm(row_loop,col_loop))>(3*max((state.varIm(row_loop,col_loop)),state.cameraNoiseVar)))
relutantIm=1;
else
resultantIm=0;
end
Now what i recieve is image that contains all zeros where as it should have some 1 i am sure about that.My values are right since i have a refrence to cross check it i believe something is wrong with my syntax.
Any helps are appreciated

采纳的回答

Image Analyst
Image Analyst 2014-4-14
编辑:Image Analyst 2014-4-14
You want resultantIm to be an entire image, right? Not just one number? So do this:
resultantIm = abs(imGray-state.meanIm) > 3*max(state.varIm,state.cameraNoiseVar);
No need for looping over row_loop and col_loop. You can do it all in one line. resultantIm is a logical (binary) image - 0 or 1, or false or true.
To get the masked foreground
foregroundImage = imGray; % Initialize
foregroundImage(~resultantIm) = 0; % Blacken background.
To get the background image:
backgroundImage = imGray; % Initialize
backgroundImage(resultantIm) = 0; % Blacken foreground.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by