Mark, Unless you average the 3, your gray-scale result may not work properly. Try it on an image with 3 circles: 100%R, 100%G, 100%B and you'll see what I mean.
On Nov 28, 2007 9:32 PM, Mark Smith <[EMAIL PROTECTED]> wrote: > This is sort of interesting: > > if you simply take one of the color bytes of each pixel, and copy it > to the other two color bytes, you get a gray-scale result. The > brightness/contrast varies with which color you choose. For the few > images I've tried, it seems to be red =brighter/less contrast to > blue= darker/more contrast. This may be no surprise to the pro image > wranglers among us, but seemed intriguing to me. > > function MakeGS @indata ---- the imageData of the source image > repeat with n = 1 to length(inData) - 3 step 4 > get char n+3 of inData ---- blue byte, 1 for red, 2 for green > put null & it & it & it after outData > end repeat > return outData > end MakeGS > > and it runs perhaps twice as fast as taking an average. > > Best, > > Mark > > > > > On 28 Nov 2007, at 23:06, Ian Wood wrote: > > > > > 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 > > _______________________________________________ > > use-revolution mailing list > > use-revolution@lists.runrev.com > > Please visit this url to subscribe, unsubscribe and manage your > > subscription preferences: > > http://lists.runrev.com/mailman/listinfo/use-revolution > > _______________________________________________ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution > > _______________________________________________ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution