Joe Maller: FXScript Reference: Building Joe's Threshold and Posterize

A description of the FXScript ideas behind Joe's Threshold and Posterize 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.

Joe's Filters
FXScript Reference

This page is incomplete

 

 

 

 

Joe's Threshold and Posterize offers an extended set of thresholding controls for Final Cut Pro.

Abstract

  1. Desaturation is applied, if selected
  2. Pre-blur is applied, if specified
  3. Threshold is applied
    1. If steps are greater than 2, steps are applied between black and white
  4. Post-blur is applied, if specified

Explanation of

The desaturation code for the first stoep of this filter is the same as Joe's RGB Desaturate applied at 100%.

 

Thresholding is a simple process; First a middle value is selected, then every value greater than the selected value becomes white, every value darker becomes black.

The levelMap() can reassign the values but first we need to build a look-up matrix for levelMap() to work with. The value threshold was set with a user input slider between 0 and 255

First a 256-value floating point array needs to be initialized:

float clut[256], i

Then a simple loop will count from the threshold value up to 255. The floating point variable i will hold the current iteration number. Using i to specify the clut entry, each loop will assign the value of 1 to every clut entry abouve the threshold. FXScript seems to assume undefined array values are equal to zero.

for i = threshold to 255
     
clut[i] = 1
next;

 

 

Joe Maller: FXScript Reference: Joe's Noise

A description of the FXScript ideas behind Joe's Threshold and Posterize 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.

Joe's Filters
FXScript Reference

Joe's Threshold and Posterize offers an extended set of thresholding controls for Final Cut Pro.See a complete explanation of controls and example images for Joe's Threshold and Posterize.

Because this filter is shareware, this explanation only explains the key concepts behind how it works rather then providing complete source code. Purchased versions of Joe's Filters are unlocked plug-ins containing the complete source code.

Abstract

  1. Desaturation is applied, if selected
  2. Pre-blur is applied, if specified
  3. Threshold is applied
    1. If steps are greater than 2, steps are applied between black and white
  4. Post-blur is applied, if specified

Explanation of

The desaturation code for the first stoep of this filter is the same as Joe's RGB Desaturate applied at 100%.

 

Thresholding is a simple process; First a middle value is selected, then every value greater than the selected value becomes white, every value darker becomes black.

The levelMap() can reassign the values but first we need to build a look-up matrix for levelMap() to work with. The value threshold was set with a user input slider between 0 and 255

First a 256-value floating point array needs to be initialized:

float clut[256], i

Then a simple loop will count from the threshold value up to 255. The floating point variable i will hold the current iteration number. Using i to specify the clut entry, each loop will assign the value of 1 to every clut entry abouve the threshold. FXScript seems to assume undefined array values are equal to zero.

for i = threshold to 255
     
clut[i] = 1
next;

A lot of people respond negatively when seeing the word "clut" for the first time. I'm not going to speculate, but it's just an abbreviation/acronym for Color Look Up Table. I don't think this variable is technically a clut, but several of Final Cut Pro's built-in filters used that name for variables, and I just got used to calling 256-value arrays cluts. Of course, the variable name doesn't matter at all.

The solution I came up with is based on this formula:

Current = current value
Target = Target value (0.33)
Desaturate = Desaturation amount from slider

Current - Desaturate * (Current -Target)

That formula is applied to the 3x3 array as follows:

How it works

I used two inputs, a popup named RGBTarget and labeled "Source"; and a slider named desat and labeled "Saturation". The slider has values go from 0 to 100.

For the matrix, I decided to enter values as variables since it was easier for me to think about, so I declared the following floating point Variables:

float rr, rg, rb, gr, gg, gb, br, bg, bb, offset0[3], mat[3][3], greypoint[3][3], temp[3][3], rdif, gdif, bdif, i;

 

 
page last modified: October 23, 2017
Copyright © 1996-2003 Joe Maller