Adaptive background Subtraction Algorithm

Hi every one

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

threshold=25
for 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);
end
end
for i=1:width
for j=1:height
if Fg(i,j)>threshold
Fg(i,j)=255;
else
Fg(i,j)=0;
end
end
end
figure(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.

SEE COMPLETE ANSWER CLICK THE LINK

--

--

--

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.

Recommended from Medium

Funny Commands of Linux

[Software Architecture] Id Sequence Number Obfuscation : Scrambler

Progressive Web Apps- All That You Need to Know

Many reasons require you to understand some basic network terminology when setting up network…

Community Incentives Program (CIP) October Update!

75% off #Create your First Computer Game with Stencyl $10

Pain Free Documentation with Elixir.

7 Major Roadblocks in DevOps Adoption and How to Address Them

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

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.

More from Medium

How do I solve imnoise error when inserting variables that store

Beginner’s guide to Supercomputers:

FastAI Bag of Tricks — Hand Sign Classification

Generating Golf Clubs with StyleGAN2-ADA : I created the new golf driver design !