Any suggestions on how to "onion skinning"?
Ian Wood
revlist at azurevision.co.uk
Wed Nov 28 18:06:41 EST 2007
On 28 Nov 2007, at 21:24, Chipp Walters wrote:
> Or, you could probably do it really fast with an optimized imagedata
> script where you average the values of each pixel and reapply. I would
> think that would zip right along.
I managed to find a function from March last year from a discussion
about making alphadata from images.
Originally written by Wilhelm Sanke, with a few tweaks by me to make
it universal for any image size.
Pass it the long ID of an image and it will return a one-channel
image suitable for a mask.
On 13 Mar 2006, at 20:51, Ian Wood wrote:
> function makeMask tMaskImg
> set the cursor to watch
> put width of tMaskImg into tW
> put height of tMaskImg into tH
> put the milliseconds into Start
> put the imageData of tMaskImg into iData
> put empty into tmaskdata
> put tW * 4 into re
> repeat with i = 0 to (tH - 1)
> repeat with j = 0 to (tW - 1)
> put chartonum(char (i*re + (j*4+2)) of idata) into tC1
> put chartonum(char (i*re + (j*4+3)) of idata) into tC2
> put chartonum(char (i*re + (j*4+4)) of idata) into tC3
> put the round of ((tc1 + tc2 + tc3)/3) into tM
> put numToChar(tM) after tMaskData
> end repeat
> end repeat
> return tMaskData
> end makeMask
Add another tweak to put it back into RGB:
function makeMask tMaskImg
set the cursor to watch
put width of tMaskImg into tW
put height of tMaskImg into tH
put the milliseconds into Start
put the imageData of tMaskImg into iData
put empty into tmaskdata
put tW * 4 into re
repeat with i = 0 to (tH - 1)
repeat with j = 0 to (tW - 1)
put chartonum(char (i*re + (j*4+2)) of idata) into tC1
put chartonum(char (i*re + (j*4+3)) of idata) into tC2
put chartonum(char (i*re + (j*4+4)) of idata) into tC3
put the round of ((tc1 + tc2 + tc3)/3) into tM
put numToChar(tM) into tPix
put tPix & tPix & tPix & tPix after tMaskData
end repeat
end repeat
return tMaskData
end makeMask
And you can do something like:
put makeMask(long id of img 1) into tData
set the imagedata of img 1 to tData
to turn the specified image into greyscale. Takes about a second for
a 640x480px image on a MBP 2GHz Core Duo, so not too speedy.
Ian
More information about the use-livecode
mailing list