This will allow the user to convert any colour image to grayscale. There are 4 "modes" to choose from. Test it to discover the differences. The code should be placed in a movieScript.
on grayScaleImg (theImage, theMethod)
grayImage = theImage.duplicate()
3:
theWidth = grayImage.width - 1
theHeight = grayImage.height - 1
repeat with x = 0 to theWidth
repeat with y = 0 to theHeight
theColour = grayImage.getPixel(point(x,y))
-- commented out one is not as rich, but brings out more detail, potentially
-- grayComp = (0.2980 * theColour.red) + (0.5882 * theColour.green) + (0.1138 * theColour.blue)
-- the below uses these fractions: 54/255 R, 182.5/255 G, 18.5/255 B
grayComp = (0.2125 * theColour.red) + (0.7154 * theColour.green) + (0.0721 * theColour.blue)
grayImage.setPixel(point(x,y), color(grayComp, grayComp, grayComp))
end repeat
end repeat
4:
theWidth = grayImage.width - 1
theHeight = grayImage.height - 1
repeat with x = 0 to theWidth
repeat with y = 0 to theHeight
theColour = grayImage.getPixel(point(x,y))
-- not as rich, but brings out more detail, potentially
-- uses these fractions: 76/255 R, 150/255 G, 29/255 B
grayComp = (0.2980 * theColour.red) + (0.5882 * theColour.green) + (0.1138 * theColour.blue)
grayImage.setPixel(point(x,y), color(grayComp, grayComp, grayComp))
end repeat
end repeat
end Case
return grayImage
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA