Professional Documents
Culture Documents
Background Subtraction
Background Subtraction
clc;
clear;
close all;
a=imread(‘b.bmp’);
f=imread(‘1.bmp’);
g=imread(‘g1.bmp’);
g=im2bw(g);
a=rgb2gray(a);
f=rgb2gray(f);
% K1=back_final(a,f);
K1=imsubtract(a,f);
K11=K1(:);
K11=double(K11);
fis = readfis(‘binary’);
Out = evalfis([K11],fis)
Out=round(Out);
Out=reshape(Out,[128 160]);
figure;
imshow(Out,[]);
Out=medfilt2(Out,[5 5]);
Out=imcomplement(Out);
[L num]=bwlabel(Out);
STATS=regionprops(L,’all’);
cc=[];
removed=0;
% h = waitbar(0,’Please wait…’);
for i=1:num
dd=STATS(i).Area;
if (dd < 1000)
L(L==i)=0;
removed = removed + 1;
num=num-1;
% imshow(L==i);
else
% imshow(L==i);
end
% waitbar(i/num,h)
end
[L2 num2]=bwlabel(L);
subplot(2,2,1);imshow(a);
subplot(2,2,2);imshow(f);
subplot(2,2,3);imshow(L2);
subplot(2,2,4);imshow(g);
[Tp,Tn,Fp,Fn,Sensitivity,Specificity]= performanceanalysis(g,L2)
disp(Sensitivity);
disp(Specificity);
disp(‘exit’);
OUTPUT