Parameters
Contents
Node Parameters Overview

All node parameters conform to a strict syntax. Parameters can represent constant values such as numbers or strings, reference values such as the names of other nodes, and even dynamic values in the form of maps or expressions. The way these are written is detailed below.

@ value [index] ::channel {f(vars)=expression}
|   |      |     |                  |
|   |      |     `-Selector         |
|   |      |              Expression'
|   |      `-Image Index          
|   `-Value-Part                 
`-Mapped Image
			
  Required for all parameters
  Required if the parameter is mapped
  Optional

Parameters which say they are 'mapped' do not actually require a mapped value. Wherever you see a mapped parameter, you can give it a constant value instead of a mapped one, and it will behave as if it weren't mapped.

Visual Example: 'Blur and Switch'
Visual Example's File
<process name="Blur and Switch">
	<node type="FileReadImage" name="inputImage" file="scenery.png"/>
	
	<node type="BlankImage" name="resultImage"
              width="640"
              height="480"/>
	
	<node type="BoxBlur" name="blurredInput" source="inputImage"
              width="10"
              height="10"/>
	
	<node type="WritePixels" name="writtenImage" source="resultImage"
              red="@blurredInput::blue{f(a)=a}"
              green="@blurredInput::green{f(a)=a}"
              blue="@blurredInput::red{f(a)=a}"/>
	
	<node type="FileWriteImage" name="resultWriter" source="writtenImage"
              file="scenery_result.png"/>
</process>
			
Explanation

This file creates a process which reads in an image into inputImage using the file "scenery.png" with FileReadImage. The image is then blurred over a 10x10 area with BoxBlur, and then it is written by WritePixels to a 640x480 image. During the writing process, the channels are swapped. Red becomes blue, and blue becomes red. The original image is also rescaled to fit within the new 640x480 image. This happens because it is written using mapped parameters. The parameters red, green, and blue on WritePixels are all mapped. After WritePixels finishes, the resulting image is written to disk as "scenery_result.png" with FileWriteImage.

Constant Values

The simplest type of parameter is a constant value. The width, height, and file parameters in the above example file are parameters which take constant values. These parameters are simply the value and nothing more. For example, the width parameter for the rescale function may be set like this: width="256". A constant value can also represent a string, such as the size parameter for the rescale function: size="50% x 50%".

Examples
width="256"
sets width to the constant numeric value 256.
size="50% x 50%"
sets size to the constant string value "50% x 50%".
Reference Values

Parameters may also be used to reference other object types, such as nodes or matrices. The most common parameter that takes a reference value is the source parameter, used to specify which node has the images to be used as the source for another node. The source parameter names another node to use images from.

Examples
source="inputImage"
If there is a node named inputImage, its images will be used as the source.
Mapped Values

Certain parameters are what Atom defines as mapped parameters. These parameters take a mapped value, which is similar to a constant value in that it is a plain numerical value, except the actual value may be taken from somewhere else, and is allowed to change as the filter is running. A mapped value consists of two parts: the value-part, and the expression-part. The value-part must be prepended with the at symbol @ in order for Atom to recognize it as mapped.

The value part can be a constant value or a reference value. Constant values are typically used when the user wants to drive the value entirely with the expression, whereas reference values are used for pulling values from external sources, such as nodes or matrices.

The expression part is written after the value part, within squiggly brackets {}. This expression is where the filter gets the final value from, and must be given. Expressions themselves are written f(variables)=expression. An example of this is f(a)=a/2. This expression takes a variable called a and returns a divided by two. Multiple variables are separated by commas, e.g. f(a,b)=a+b.

The simplest expression you can write is {f(a)=a}. This expression has no effect, it simply passes through the value of a. The variable a typically ranges from 0.0 to 1.0 when sampling from another node. Every expression is required to use the variable a, but may optionally use four other variables: x, y, u, and v. x and y are pixel coordinates for the filter's current position at the time of sampling, where u and v are normalized coordinates for the filter's current position, where 0.0 is the first pixel and 1.0 is the last pixel on a particular axis; u corresponds to x and v cooresponds to y.

Examples
hue="@myMatrix{f(a)=a}"
This is the simplest possible mapped parameter, taking hue values from the matrix myMatrix as the filter processes an image. Notice the value-part myMatrix and the expression-part {f(a)=a}.
hue="@myMatrix{f(a)=a * 2}"
Identical to the example above, except the expression-part of the parameter will multiply every value from the matrix by two before giving it to the filter.
bias="@maskImage{f(a)=1 - a}"
This example is using the values from an image on the node maskImage to drive the bias parameter of a filter. Before being given to the filter, the value is subtracted from 1 by the expression, effectively inverting it.
red="@0{f(a,u,v)=sin(u * 3.14) + cos(v * 3.14)}"
Here we see a mapped parameter which is completely driven by an expression. The value-part is simply the constant 0, which is ignored by the expression since it never does anything with the variable a. Instead, it takes the u and v coordinates and generates sine and cosine waves from them.
green="@5{f(a,u)=sin(a * u * 3.14)}"
And similarly, here we are using a constant value in the value-part to drive the frequency of a sine wave along u. This will generate a 5hz sine wave.
Channel Selectors

Sometimes you want to use a specific channel from an node's images, such as red, green, or blue. To do this, you use two colons :: after the node reference, followed by the name of the channel you want. An example of this is inputImage::red. When used in mapped parameters, selectors must come before the expression-part. In mapped parameters, when no selector is specified, the default is ::gray, since the value must be condensed into one variable, a.

Examples
source="inputImage::red"
If there is a node named inputImage, only the red channel from its images will be used.
saturation="@inputImage::blue{f(a)=a}"
Maps the blue channel to the variable a in order to drive the saturation parameter.
Image Indexers

Nodes are allowed to output more than one image as a result of their filter. When this happens, another node can select an individual image to use from this node by using the square brackets [] after the node reference, with the desired index between the brackets. An example of this is inputImage[0]. When used in mapped parameters, indexers must come before the expression-part. Indexers must also come before channel selectors.

Examples
source="inputImage[0]"
If there is a node named inputImage, then only the first image will be used.
source="inputImage[0]::green"
Same as above, but now we are only selecting the green channel.