Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Background subtraction
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Sanjeev

Posts: 4
Registered: 12/27/12
Background subtraction
Posted: Jan 20, 2013 12:56 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

this is my code for background subtraction. i tried making use of 2 push buttons to start and stop the processing. but as soon as i click the START push button the GUI window disapears and i cant stop the processing. what is it that i have 2 do?


clc;
close all;
clear all;

source = videoinput('winvideo');
set(source, 'ReturnedColorSpace', 'RGB');
set(source, 'FramesPerTrigger', 1);
set(source, 'TriggerRepeat', 50);
triggerconfig(source, 'manual');
start(source);
thresh = 15/255;
pause(2);
trigger(source);
bg = getdata(source,1,'double');
bg_bw = rgb2gray(bg);

fr_size = size(bg);
width = fr_size(2);
height = fr_size(1);
f = zeros(height, width);

for i=1:50

trigger(source);

fr=getdata(source,1,'double');
fr1=fr(:,:,:,1);
fr_bw1=rgb2gray(fr1);

bg_fr_diff = abs((double(bg_bw)) - (double(fr_bw1)));

for j=1:width % if fr_diff > thresh pixel in foreground
for k=1:height
if (bg_fr_diff(k,j) > thresh)
f(k,j) =255;
else
f(k,j) = 0;
end
end
end
figure(1),subplot(2,1,1),imshow(fr1)

subplot(2,1,2),imshow(uint8(f))
bg_bw=fr_bw1;



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.