Page 1 of 1
MEL question: scanning rgb values from images
Posted: Mon Mar 26, 2007 8:28 pm
by deadalvs
how to achieve this ?
let's say i have a 100x75 px, some of the pixels are colored.
if i wanted to loop through x and y pixels and create a vector array of the image's rgb values of each pixel... how would i do that in MEL ?
* * *
thanks for any ideas...
Posted: Mon Mar 26, 2007 8:57 pm
by 3dtrialpractice
saw this onhighend.
maybe itll help?
aiConditionArray 1.0.0
"You can use this plugin in rigging when you would usually have a lot of rgb condition nodes.
The node is currently being used in production at A. Film"
http://www.highend3d.com/maya/downloads ... nArray.zip
Posted: Mon Mar 26, 2007 8:59 pm
by deadalvs
thanks for the tip !
i am currently trying the colorAtPoint command...
it's not yet working... takes some time, as always...

Posted: Mon Mar 26, 2007 9:11 pm
by deadalvs
ah, this is good:
this samples not directly the pixel's value but the uv-position (firstly calculated by the pixel-ratio)...
5: 5th pixel
15: total of 15 pixels
* * *
float $X = (5/15);
float $Y = 1-(5/15);
print("U = " + $X + " and V = " + $Y);
vector $imgColor = `colorAtPoint -o RGB -u $X -v $Y file1`
* * *
found here:
http://store.digital-tutors.com/chit_ch ... hp?p=13266
Posted: Thu May 03, 2007 10:38 am
by deadalvs
this is better:
this samples each pixel in the middle of the pixel, and not at the edge as the other script does.
* * *
int $pxU = 2;
int $pxV = 2;
int $resU = 15;
int $resV = 15;
float $FloatpxU = $pxU + 0.00001;
float $FloatpxV = $pxV + 0.00001;
float $FloatresU = $resU + 0.00001;
float $FloatresV = $resV + 0.00001;
float $X = ( ($FloatpxU/$FloatresU) + (($FloatpxU-1.0)/$FloatresU) ) / 2.0;
float $Y = 1-(( ($FloatpxV/$FloatresV) + (($FloatpxV-1.0)/$FloatresV) )/2.0);
print("U = " + $X + " and V = " + $Y);
vector $imgColor = `colorAtPoint -o RGB -u $X -v $Y file1`;