Filter löschen
Filter löschen

How to update a background model in motion detection

1 Ansicht (letzte 30 Tage)
Lora
Lora am 14 Apr. 2014
Kommentiert: Lora am 14 Apr. 2014
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

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Apr. 2014
Bearbeitet: Image Analyst am 14 Apr. 2014
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.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox 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!

Translated by