Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-24-2008, 04:21 PM   #1
adamsnk
Registered User
 
Join Date: Aug 2008
Posts: 8
Default 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);
adamsnk is offline   Reply With Quote
Old 08-24-2008, 05:42 PM   #2
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

Why won't you use BitmapData.treshold()?
Here's a simple example of using it. It's not exactly what you need, but really close.
http://www.actionscript.org/forums/s...black+treshold
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 08-24-2008, 06:30 PM   #3
adamsnk
Registered User
 
Join Date: Aug 2008
Posts: 8
Default

thanks wvxvw, but I have actually experimented already with the threshold that is built in, but it is not giving me the results I need. It is important for this project that absolutely no detail shows up in the silhouette, and I am still getting thresholdy type shade and light showing up even after tweaking quite a bit.
I have now realised that the bytearray from an image works such that each item in the array carries alpha, red, green, blue information alternatively, so have slightly changed this program to deal with that but still getting no dice.
Any ideas?
thanks
adamsnk is offline   Reply With Quote
Old 08-24-2008, 07:12 PM   #4
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

For bytearrays it you'll have to elaborate some really sophisticated algorithm... and no way it will be faster than using treshold few times...
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
question regarding layer jungyung ActionScript 1.0 (and below) 2 10-02-2006 10:57 AM
3 specific question about forms k_os Components 3 03-28-2005 05:35 PM
Multiple answers to 1 question in Flash Quiz? milohound ActionScript 1.0 (and below) 8 02-20-2005 11:11 PM
[AS1] Swapdepth using txt files and dynamic content for game. superbnerb Gaming and Game Development 3 09-22-2004 07:27 PM
Game "Time Delay" after question is answered kunafish Gaming and Game Development 1 07-29-2002 07:04 PM


All times are GMT. The time now is 06:01 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.