| Home Introduction User's Guide Download

| OnSubtract: |  |

| NAME OnSubtract ¨C thresholding the subtraction of two images SYNOPSIS sub_img = OnSubtract( Img1, Img2, thre) PARAMETERS
Img1,Img2 ĦĦMĦÁNĦÁ3 matrix for ture color image, MĦÁN matrix for binary and intensity image
thre ĦĦ ĦĦThe threshold for subtraction
sub_img ĦĦMĦÁN matrix with the value of 0 or 1, considering to be the binary image.

DISCRIPTION

Function OnSubtract thresholding the subtraction of two images . This function is useful for both the temporal differencing and the background substraction methods.

EXAMPLE

//background subtraction demo
initial_dir = PWD;
chdir (VIPDIR + 'videos');
szFile = 'car.avi';
newFile = 'car_backsub.avi';
pfi = OpenAviFile(szFile);
back_pos = 5;
thre = 30;
back_frame = AviReadFrame(pfi, back_pos);
if pfi <> []
ĦĦĦĦnew_ppavi = CreateAviFile(newFile, 100, pfi(3), pfi(4), pfi(7), pfi(8));
ĦĦĦĦdisp("waiting for writing.....");
ĦĦĦĦif new_ppavi <> []
ĦĦĦĦĦĦĦĦfor i=100:199
ĦĦĦĦĦĦĦĦĦĦĦĦdata=AviReadFrame(pfi, i);
ĦĦĦĦĦĦĦĦĦĦĦĦdata = OnSubtract( data, back_frame, thre);
ĦĦĦĦĦĦĦĦĦĦĦĦAviWriteFrame(new_ppavi, data);
ĦĦĦĦĦĦĦĦĦĦĦĦdata=[];
ĦĦĦĦĦĦĦĦĦĦĦĦnew_ppavi(6)=new_ppavi(6)+1;
ĦĦĦĦĦĦĦĦend
ĦĦĦĦĦĦĦĦAviWriteEnd(new_ppavi);
ĦĦĦĦend
ĦĦĦĦAviReadEnd(pfi);
end
chdir(initial_dir);

See also
OpenAviFile, AviReadFrame, AviReadEnd, CreateAviFile, AviWriteFrame, AviWriteEnd

back

Entry
Home Introduction User's Guide
Function Reference
SIP Functions New Image Func Video Functions
Developer's Guide
Graphical Display Video Processing Modified Functions GUI
Demo
Image Processing Video Processing
Support
Future Work Known Bugs FAQ Acknowledgement About Us

|  |  | About Us | Contact Us | Our University Copyright © 2004-2005 Scilab group of Xiamen University, China |  |