フィルターのクリア

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.
  1 件のコメント
Lora
Lora 2014 年 4 月 14 日
Thanks a lot really

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by