필터 지우기
필터 지우기

How to update a background model in motion detection

조회 수: 2 (최근 30일)
Lora
Lora 2014년 4월 14일
댓글: Lora 2014년 4월 14일
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