Jump to content

ColorMatrixFilter documentation ?


bali33
 Share

Recommended Posts

I've stared at that thing for a long time.  It's similar to the flash documentation on their 4x5 matrix.  But it's missing the 5th column (offset), which is a source of frustration for me.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/ColorMatrixFilter.html

 

Every pixel's color and alpha values are multiplied in the matrix.  The following matrix produces no change in the pixel.

  R G B AR 1 0 0 0G 0 1 0 0B 0 0 1 0A 0 0 0 1 

So let's say I have a pixel with the following color: 0x010203 and alpha of 1 and pass it through a matrix like this:

2.0  0.0  1.0  00.0  0.5  0.0  00.0  0.0  0.0  00.0  0.0  0.0  1

The pixel's new value will be calculated as follows:

R = 2*1 + 0*2 + 1*3 + 0*1;

G = 0*1 + 0.5*2 + 0*3 + 0*1;

B = 0*1 + 0*2 + 0*3 + 0*1;

A = 0*1 + 0*2 + 0*3 + 1*1;

 

Which is 0x050100 with an alpha of 1.  Essentially, we removed all the blue and doubled the red and added even more redness where there used to be blue.  The green was reduced by half.

 

Common use cases include brightening/darkening an image (multiply all colors by an equal amount above/below 1) and grayscale an image (multiply all colors together).

 

And if that is still confusing I defer to a random article I found:

http://code.tutsplus.com/tutorials/manipulate-visual-effects-with-the-colormatrixfilter-and-convolutionfilter--active-3221

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...