View Full Version : get average pixel rgb value

12 December 2003, 10: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?


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

12 December 2003, 03: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

12 December 2003, 05: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

01 January 2004, 12:29 PM
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 ?


01 January 2004, 01: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


01 January 2004, 10:08 AM
Yes sure I got it...sorry can't help you with that.


CGTalk Moderation
01 January 2006, 02: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.