1 Reply Latest reply on Feb 23, 2011 6:50 PM by unique_screenname_here

    White Balnce  Filter for flash

    GiladAv

      Hello,

       

      I'm a new Pixel Bender user and i want to create a White Balnce  Filter for flash, that for each image received I will check if is it too light or too dark and will fix it. I used the following mathematical code:

       

      var_R = ( R / 255 )        //R from 0  to 255
      var_G = ( G / 255 )        //G  from 0 to 255
      var_B= ( B / 255 )        //B from 0 to 255
          input image4 src;
          output pixel4 dst;

          void
          evaluatePixel()
          {
         
              dst = sampleNearest(src,outCoord());
             
              float var_R = (dst.r / 255.0 );        //R from 0 to 255
              float var_g = (dst.g / 255.0 );      //G from 0 to 255
              float var_b = (dst.b / 255.0 );      //B from 0 to 255
             
              if ( var_R > 0.04045 )
              {
              var_R = ( ( var_R + 0.055 ) / 1.055 ) ^ 2.4;
              }
              else
              {
              var_R = var_R / 12.92;
              }
              if ( var_G > 0.04045 )
              {
              var_G = ( ( var_G + 0.055 ) / 1.055 ) ^ 2.4;
              }
              else
              {var_G = var_G / 12.92;
              }
              if ( var_B > 0.04045 )
              {
              var_B = ( ( var_B + 0.055 ) / 1.055 ) ^ 2.4;
              }
              else
              {
              var_B = var_B / 12.92;
              }

          dst=float4[var_R * 100,var_G * 100, var_B * 100,dst.a];

          }
      }


      I would be happy if you help me with the Syntax or with ideas for the code.


      1. How to do Power in the Pixel Bender?
      2. If anyone has an idea or code that he wrote before I'd  be happy if he could share with me.

      Many thanks in advance

       

      GiladAv