[PD] GEM : fx to make persons appear only when they move
Denis Trapeznikoff
denissimo at gmail.com
Mon Mar 5 15:25:25 CET 2007
Sorry, if offtopic. I'm not aware of GEM functionalities, but the
algorythmic way to solve the problem, as I can see it, is:
compute diff(x,y)=f(t,x,y)-f(t-1,x,y), where f(t) is picture at present
moment;
compute alpha layer for the current picture alpha(x,y)=(diff(x,y)!=(0,0,0))
for example, in C code the predicate "pixel difference
does not equal zero" could be written as
char tmp = (char)(diff[x,y].red | diff[x,y].green |
diff[x,y].blue);
alpha[x,y] = (unsigned char)((tmp | -tmp) >> 7); /*
the result is: 0 for 0 and 255 otherwise */;
blend initial background and current picture with computed alpha layer.
The second step requires per-pixel computations and takes 5 byte-arithmetics
per pixel (3 bitwise ORs, signed shiftright and negation, which in turn
could be expanded to bitwise NOT and subtraction, machine-dependent), thus
on a 320x240 24bpp picture taking overall 384000 (or 460800, with
subtractions from the first step) integer byte-arithmetics, which is three
of five orders of magnitude below the performance of modern CPUs.
Hmmm... what am I talking about?..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20070305/f88a91c7/attachment.htm>
More information about the Pd-list
mailing list