1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
% This function subtracts current background (currentBckd) to the channel we use
% (currentImage) and outputs a map containing values between 0 and 1, 1 indicating
% a high probability that the pixel here is moving
% Input parameters:
% currentRedImage : wxh current red image
% currentGreenImage : wxh current green image
% currentBlueImage : wxh current blue image
% currentRedBckgd : wxh current red background image
% currentGreenBckgd : wxh current green background image
% currentBlueBckgd : wxh current blue background image
% Output parameters:
% foreGroundMap : wxh foreground map with values in [0,1]
function foreGroundMap = ...
bckgdSubtract(currentRedImage,currentGreenImage,currentBlueImage,...
currentRedBckgd,currentGreenBckgd,currentBlueBckgd);
% Do the difference
% TO BE FILLED
currentRedImage=double(currentRedImage);
currentRedBckgd=double(currentRedBckgd);
currentGreenImage=double(currentGreenImage);
currentGreenBckgd=double(currentGreenBckgd);
currentBlueImage=double(currentBlueImage);
currentBlueBckgd=double(currentBlueBckgd);
R=currentRedImage-currentRedBckgd;
G=currentGreenImage-currentGreenBckgd;
B=currentBlueImage-currentBlueBckgd;
difference=sqrt(R.^2+G.^2+B.^2);
%R=cast((currentRedImage-currentRedBckgd).^2, 'double');
%G=cast((currentGreenImage-currentGreenBckgd).^2, 'double');
%B=cast((currentBlueImage-currentBlueBckgd).^2, 'double');
%difference=sqrt(R+G+B);
%A=max(vabs(R) + vabs(G) + vabs(B));
% Outputs a probability map
% TO BE FILLED
foreGroundMap = 3 .* difference ./ (currentRedBckgd + currentGreenBckgd + currentBlueBckgd);
% foreGroundMap = difference; |
Partager