Graphic Algorithm needed... sepia/solarize etc
Results 1 to 3 of 3

Thread: Graphic Algorithm needed... sepia/solarize etc

  1. #1

    Graphic Algorithm needed... sepia/solarize etc

    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?

  2. #2
    nothing?
    noone?
    and only 3 views?

  3. #3
    Junior Member
    Join Date
    May 2009
    Posts
    1

    Try this out

    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
    Code:
    		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:
    Code:
    			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/...9291920,00.htm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •