bytearray question
Hi,
I have been trying to use threshold to achieve background subtraction, but I am having no joy with that, so I have decided to try using byte arrays instead.
I want to take two byte arrays and compare them to make a new composite image, also to be stored in a byte array. Where the pixels are the same I want to make a the resulting image's pixel black, where they are different, I want to make it appear white in the resulting image.
I can't seem to get it to work.
If anyone can see what I am doing wrong in this code, please help!
Thanks
PS this code is a function which repeats every frame.
//this like draws my webcam into bitmapdata of the foreground
fg.draw(video);
//this creates a new rectangle the size of the stage
var rect:Rectangle = new Rectangle(0,0,550,400);
//this makes a bytearray of the pixels in the video stream
fgarray = fg.getPixels(rect);
//now compare this array to one previously made of the background and apply change to the empty bytearray resarray (resulting array)
for (var i:int=0;i<880000;i++)
{ if(bgarray[i]==fgarray[i]0{
resarray[i]=0xFFFFFFFF;
}else{
resarray[i]=0xFF000000;
}
}
//now set the pixels to be displayed from the resulting array resarray
fg.setPixels(rect, resarray);
|