Image interpolation between colors

Problems with Canvas, OpenGL, etc...

Image interpolation between colors

Postby lordraider » Wed Jan 11, 2012 10:57 pm

Hello,

I want to make a thermal vision like filter effect on a image but I'm a bit stuck.
The gradient goes from Blue->Yellow->Red.

Yellow to Red goes smooth but Blue to Yellow is not smooth with color bumps from green and blue.

This is the effect I want
Image
With my code everything from yellow to red is ok but from blue to yellow goes wrong.

I wrote the method below. What could be the problem?

Code: Select all
public void thermalVision()
   {
      size = width * height;
      float r, g, b;
      float redTemp, yellowTemp, blueTemp;
      float luminance = 0;
      float result;
      index = 0;
      redTemp = 0xff000000 | (255 << 16) | (0 << 8) | 0;
      yellowTemp = 0xff000000 | (255 << 16) | (255 << 8) | 0;
      blueTemp = 0xff000000 | (0 << 16) | (0 << 8) | 255;
      while(index < size)
      {
         
         r = Color.red(rgbInput[index]);
         g = Color.green(rgbInput[index]);
           b = Color.blue(rgbInput[index]);
       
       
           luminance = (float)((float)(r+b+g)/3)/255;
           if (luminance < 0.5)
            {
              luminance =  (float) ((luminance*0.5)/0.5);
              result = blueTemp *(1-luminance) + yellowTemp * luminance;
               
            }
            else
            {
               luminance = (float) ((luminance-1*0.5)/0.5);
               result = yellowTemp *(1-luminance) + redTemp * luminance;
            }
          
           output[index] = 0xff000000 | (int) result;
           index++;
      }
lordraider
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 11, 2012 10:50 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests