2 Replies Latest reply on Aug 30, 2007 5:21 AM by Pop_Clingwrap

    RGB to Grayscale conversion

    Pop_Clingwrap Level 1
      I have been messing around trying to get script an RGB to Grayscale function. I have cobbled this together from various sources on bitwise calculations and two conversion formulas I found on a C# forum (gray = (R+G+B)/3, gray = 0.3*red+0.59*green+0.11*blue). This approach works but runs like an unhealthy, steam powered dog (hence doing it pixel by pixel in an Interval rather than in for loops). Can anyone suggest a better approach, give advice on optimising this code or advice on using these conversion formulas with the ColorTransform class to achieve the effect?

        • 1. Re: RGB to Grayscale conversion
          Level 7
          doing it pixel by pixel is definitely NOT the way to do. why not simply use
          the 'ColorMatrixFilter' which affect the entire bitmap at once??
          try doing some research on that, and get back to me if you don't reach any
          helpful conclusions.

          good luck,

          • 2. Re: RGB to Grayscale conversion
            Pop_Clingwrap Level 1
            Cheers for the pointer. After a little searching I found more precise multipliers to use and got it all working in a ColorMatrixFilter. It took a lot of fiddling to get the right result but I found loads of cool effects along the way (I didn't know there was so much control available over colors etc!)

            If you have any good resources on matrices I would love to see them as I still don't understand why what I have here works.
            Thanks again