so I've been looking around the net and have found nothing. I need some cool image algorithms.
I want sepia tones and solarized, but anything will be cool.
I already have:

grayscale:
for all pixels
getRGB
c = (r+b+g)/3
setRGB c<<16+c<<8+c

and invert:
for all pixels
getRGB
r = 255-r;
g = 255-g;
b = 255-b;
setRGB r<<16+g<<8+b

any others that people can think of?

    6 years later

    Seriously, i dunno how noone explained to you yet, i'm not a php programmer so i'll try to explain to you the algorithm.
    First of all you should convert it to grayscale in other way.
    The way a television turns a color image to grayscaled one is multiplying the R, G and B for a factor from 0 to 1;
    So grayscale pixel convertion should be something like

    		var pixelColor:uint = copiaClip.getPixel32(j, i); //32bit pixel
    			var pixelAlpha:uint = pixelColor >>> 24;
    			var R:uint = pixelColor >>> 16 & 0xFF;
    			var G:uint = pixelColor >>> 8 & 0xFF;
    			var B:uint = pixelColor & 0xFF;
    			var GrayColor:uint = (redFactor * R)  + (greenFactor * G) + (blueFactor * B);
    			//Restringir cores
    			if (GrayColor<0) { GrayColor = 0;}
    			if (GrayColor>255) { GrayColor = 255;}
    			//var GrayFactor:uint = (R+G+B)/3; Este seria o metodo de conversão simples, mas queremos controlar a quantidade de cores
    			var pixelGray:uint = (GrayColor << 16) | (GrayColor << 8) | GrayColor;
    			if (pixelGray <= 0) {pixelGray = 0;}
    			copiaClip.setPixel32(j, i, pixelAlpha << 24 | pixelGray);

    Now the sepia, as you should know by now, it's the gray pixel multiplied by a certain number, so, you pick the GrayColor, extract the R G B values and multiply them, in example:

    			var SepiaToneR:uint = (R * 0.393)+(G * 0.769)+(B * 0.189);
    			var SepiaToneG:uint = (R * 0.349)+(G * 0.686)+(B * 0.168);
    			var SepiaToneB:uint = (R * 0.272)+(G * 0.534)+(B * 0.131);
    			if (SepiaToneR > 255) SepiaToneR = 255;
    			if (SepiaToneG > 255) SepiaToneG = 255;
    			if (SepiaToneB > 255) SepiaToneB = 255;
    			if (SepiaToneR < 0) SepiaToneR = 0;
    			if (SepiaToneG < 0) SepiaToneG = 0;
    			if (SepiaToneB < 0) SepiaToneB = 0;

    This is the way i do it, hope it helps.
    BTW, found the values in here http://www.builderau.com.au/program/csharp/soa/How-do-I-convert-images-to-greyscale-and-sepia-tone-using-C-/0,339028385,339291920,00.htm

      Write a Reply...