Joe Maller: FXScript Reference: Building Joe's PixelizerThe FXScript concepts behind my pixelization filter for Final Cut Pro |
|
Visit the New FXScript Reference and Joe's Filters sites. These pages will be phased out soon and may already be out of date. This page describes the FXScript concepts behind Joe's Pixelizer. If you're looking for the page about how to use the filter, click here. OverviewJoe's Pixelizer uses a pair of loops to represent the original image with large blocks of various shapes. The first loop repeats once for each row in the image, the second loop is nested inside the first loop and draws a row of blocks across one row based on the color of the spot it is over. After the second loop finishes, the first loop starts again one row lower. This sort of process is called a recursive operation. Throughout the following explanations, "pixels" will refer to the original image pixels and "blocks" will refer to the drawn squares, circles or diamonds. The first BlockThe most important piece of information in this script is the location of the current block. The two loops will increment this value to fill the image with blocks. I called the variable
Because Because Essence of the PixelizerBelow is a simplified version of the two nested loops which make Joe's Pixelizer work. I removed several of the customizing options to make things easier to see.Values for increasing spacing or adding random scatter are just glommed on in the appropriate spot to modify the
RandomnessFXScript's The "Dancing Scatter" checkbox in Joe's Pixelizer determines whether randomly spaced blocks will be in the same place for each frame or if their values will be recalculated for each frame. Beacause the checkbox will return a zero or one, it's value could be fed into I could have used a simple if/then statement to reverse the value, which might have looked like this:
Instead I came up with a little arithmetic trick to reverse the values:
This makes me happy because of how simple it is. The checkbox returns either zero or one. If the checkbox is unchecked (returns a zero): Anything multiplied by zero equals zero, so adding one to that will result in the opposite value. If the checkbox is checked (returns a one): The initial multiplication will reverse the one, changing it to a negative. Adding one to negative one equals zero. So that little statement will work to reverse both possible values. I don't know for sure if math is faster than if/then statements, but mathmatical solutions seem cleaner and more elegant. There is an operation called bit-shifting, but I don't fully undersand that yet. After explaining the math above, I'm wondering if bit-shifting would be even faster. There's always more to learn (which is why sleep frustrates me). Wrapping upThe above loops draw the pixels into an extra image buffer, xbuffer. My standard set of compositing controls is nested inside an if/then statement which considers the Transparent Background checkbox before finishing up the filter. If the checkbox is checked,
ConclusionThis is one of my most complicated filters, but is built around a very simple, repetitive process. My biggest stumbling point was the vertical gapping between blocks, which took a few days to figure out. Figuring out the main loops took the most time, adding extra adjustments and features onto the working loops went smoothly. The complete FXScript source code for Joe's Pixelizer is included with the paid version of Joe's Filters. |
The FXScript ReferenceFXScripting Joe's FiltersJoe's Filters for Final Cut Pro Building Joe's Minimum Maximum Joe's FXScript ExplorersJoe's Debug and Explore Filters Joe's 3x3 Convolve Matrix Tester Joe's 3x3 Matrix Values Tester Other FCP Stuff
Film & VideoRecording the sound of PhotographyProjectsFinal Cut ProDesignWRITINGSite Notes Archive (weblog) Web ResourcesAbout Joe MallerPast Home Pages Etc.Search joemaller.comContact Me
|