Adaptive background Subtraction Algorithm
Show older comments
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.
Thanks in advance
Accepted Answer
More Answers (2)
Laura Proctor
on 24 Dec 2012
There are a couple things that I notice in this code. First, I'm not sure, but I think that you might want to apply the threshold to each frame, in which case, you should put the threshholding inside the for loop when reading each frame. Second, you can achieve this threshholding without using a for loop.
Try this:
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
Fg(Fg>threshold) = 255;
Fg(Fg<=threshold) = 0;
figure(2);imshow(Fg);
drawnow;
pause(0.2)
end
6 Comments
Algorithms Analyst
on 24 Dec 2012
Algorithms Analyst
on 24 Dec 2012
Nusrat jahan
on 1 Feb 2019
why i found error in :
for f=1:frames
undifined function or variable frames ?
Image Analyst
on 2 Feb 2019
You have to determine the number of frames in your video before you call that code.
matin
on 24 Mar 2020
could you please tell me what obj and f are in this code?
Image Analyst
on 24 Mar 2020
f is the frame number that you want to read. obj is what you get returned when you call VideoReader. What you have is just a snippet that left out a fully working demo. See my answer below for several video processing demos.
Image Analyst
on 24 Mar 2020
0 votes
See several attached video processing demos.
1 Comment
Fego Etese
on 24 Mar 2020
Please Image Analyst, I need your help on this question https://uk.mathworks.com/matlabcentral/answers/512047-how-can-i-find-out-if-two-minutiae-points-in-a-fingerprint-image-are-on-the-same-ridge
Sorry for the bother, but i really need your help as I am lost.
Thanks.
Categories
Find more on Image Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!