PDA

View Full Version : get average pixel rgb value


j00ey
12-31-2003, 09:57 AM
hi all

i once wrote a script in maxscript to take an image and calculate the average of all the pixels' rgb values, and now i need the same thing in maya and my mel is basic to say the least.

i dare say i could work it out but i wondered if anyone has any tips or knows perhaps if there is such a script floating around somewhere.

what i want it for is a scene where i have a character watching tv in a dark room and i want to use a single area light to light him, with its colour derived from an image sequence playing on the tv.

any ideas?

thanks
j00ey

-----------------------------------------
mods - sorry, posted this in wrong forum before
feel free to delete thread in maya forum
thanks
j
------------------------------------------

playmesumch00ns
12-31-2003, 02:42 PM
Mel doesn't expose any direct image manipulation functionality, although there are plugins or scripts available to get an iff image as an array of pixels. You can then loop over this array and take the average, could be quite slow depending on the resolution of your image.

A much better way of doing this would be to just scale you image sequence down to like 2 pixels square and plug this in to the light's colour

j00ey
12-31-2003, 04:53 PM
thanks ch00ns
i'll see what it looks like doing it that way. perhaps a heavy heavy blur then resize would do pretty much the same
happy new year
j00ey

thematt
01-04-2004, 11:29 AM
Ok sorry probably I don't really understand what you're trying to do..but why putting the sequence of image directly in the color of the light would't work ?..isn't what you're after ?

cheers..

j00ey
01-04-2004, 12:29 PM
thematt - i don't want the light to project the image sequence - i was just trying to get a dull single color light to illuminate the scene as if the light were coming from a tv in a dark room. a tv doesn't project an image of what its displaying as the light emitted from it is so diffused by the time it hits anything [unless of course the object is right up against the screen]

thanks anyway though for replying

j00ey

thematt
01-05-2004, 09:08 AM
Yes sure I got it...sorry can't help you with that.

cheers

CGTalk Moderation
01-17-2006, 01:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.