Joe Maller: FXScript Debug and Explore: Joe's 3x3 RGB Matrix TesterA tool for visualizing how FXScript uses RGB matrixes and how changing the matrix affects color.
This filter demonstrates the effects of changing values in a 3x3 RGB ColorTransform matrix.
The basic matrix for this filter looks like this:
It works sort of like a multiplication table, the rows are outputs and the columns are inputs. The first letter corresponds to the color channel of the source or input. The second letter is the output. A value of 1 is equal to 100% of that channel being sent to the output, to preserve the luminance of the image, the combined total output for the entire matrix should equal 3.
For an image to go straight through without being changed, Red needs to go to Red (RR) Green to Green (GG), and Blue to Blue (BB). Colors can be mixed up by sending one channels source to anothers output, something like RG (red to green) and GR and BB would reverse the Red and Green color channels but preserve the Blue. For a monochrome image, send one channel to all three outputs: RR, RG, RB will result in a grayscale image based on the Red channel.
An averaged desaturation would place three fractional values in each channel, with each column totalling 1. For simplicity's sake, I averaged each value down to 1/3. Another method (which I might add in the future) would be to average down to the corresponding luminance values:
The first three sliders control the Red channel, the second three control the Green and the third set controls the Blue.
The labels should be pretty clear, R to R is Red to Red, R to G is Red to Green, etc. The filter's default values are set to display the unchanged image.
How it works
The filter starts out with the standard definition of filter name and group:
Next is a set of nine inputs, representing the values that will be assigned
to the matrix. The input variables (
The lines containing
Next comes the code divider to separate the code from the definitions:
First the script declares the variables.
And finally, the ColorTransform function:
Because nothing was ever assigned to the