Hi every one

I have a problem while applying threshold into the Adaptive background Algorithm My code is

`threshold=25for f=1:frames                 I=read(obj,f);      figure(1);imshow(I);title('Input Video Sequence');        if f==1         Background=I;         Fg=abs(I-Background);   else     Fg=abs(I-Background);    endendfor i=1:width  for j=1:height    if Fg(i,j)>threshold      Fg(i,j)=255;    else      Fg(i,j)=0;    end    endendfigure(2);imshow(Fg);`

This is a video file in which I am applying this algorithm but when I apply the threshold conditions the results does not effect and I cannot get the foreground mask.

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

After you get through the first loop over frames, FG will have the value of the last iteration because you keep overwriting it on each iteration and never do anything with it. So after that loop ends, FG is just the last frame minus the first frame. Clearly not what you want to do. Then you’re thresholding FG, which is just the last difference like I said, and displaying it.

Put the background modification and the thresholding inside your loop over frames, and display inside that loop, or else assign a frame FG{f} to store all your difference frames. I added just a few lines to my demo (which I’ve posted before) to handle your adaptive background stuff. Copy, paste, and run this code:

`% Demo macro to extract frames and get frame means from an avi movie% and save individual frames to separate image files.% Also computes the mean gray value of the color channels.clc;    % Clear the command window.close all;  % Close all figures (except those of imtool.)imtool close all;  % Close all imtool figures.clear;  % Erase all existing variables.workspace;  % Make sure the workspace panel is showing.fontSize = 14;% Change the current folder to the folder of this m-file.% (The line of code below is from Brett Shoelson of The Mathworks.)if(~isdeployed)  cd(fileparts(which(mfilename)));end% Open the rhino.avi demo movie that ships with MATLAB.folder = fullfile(matlabroot, '\toolbox\images\imdemos');movieFullFileName = fullfile(folder, 'rhinos.avi');% Check to see that it exists.`

--

--

--

## More from Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

## Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.