Pixel math reference
Use Pixel math to calculate a new color or decide where a layer applies. For each pixel, Studio can read the stretched value of a named input such as Ha. An adjustment can also read the color already assembled beneath it. Once you apply an expression, changing an input stretch or a contributing layer automatically updates the result. Compare all eleven templates or follow a worked edit.
Apply an expression
- For a color change, select a layer under Combine and choose Adjustment, then Pixel math. The new layer starts with One for RGB and the expression
t, which passes each channel through. Choose Split when red, green and blue need different calculations. Studio keeps the expressions you enter in each mode.Open Adjustment. Pixel math is the last item in the menu. - For a mask, select the layer you want to limit. Under Computed from inputs, choose New mask for this layer. Studio assigns the mask and opens its inspector. Select Mask to inspect the coverage or Picture to see its effect.
Choose the marked button on the layer you want the mask to control. - Click the expression in the inspector. Enter a formula or select a suggested name as you type. Apply the expression to refresh the canvas. If Studio finds an error, the editor stays open with the reason and the picture keeps its last applied expression.
This applied expression lifts each channel’s midtones. Click the marked field to edit it.
| Action | Key |
|---|---|
| Select a suggestion | ↑ or ↓ |
| Insert the selected suggestion | Tab |
| Start a new line | Shift + Enter |
| Apply the expression | Enter |
| Discard the current text edit | Esc |
Choose which pixels to read
tor$T· current channel- On an adjustment, Studio reads the channel it is calculating from the picture beneath the layer. In One for RGB,
t * 0.8multiplies red, green and blue separately by 0.8. In the Green field under Split,treads green. r,g,b· color beneath the adjustment- These read red, green and blue at the same pixel. All three output expressions read the same incoming picture. Editing the red expression cannot change the value of
rread by the green expression. l· luminance beneath the adjustment- Studio weights the incoming red, green and blue using the picture’s working color space. Enter
lin One for RGB to put that brightness into all three channels and produce a grayscale picture. - Input name · stretched input
- In an adjustment or mask, use an input from the open document, such as
red,Ha,OIIIorSII. Each value comes from that input after its own Stretch, wherever it appears in the layers. In an adjustment,redreads the red input whilerreads the composite red beneath the layer. For a separated stars input, the editor may offer a name such asha@stars.
A computed mask reads named inputs and constants. The adjustment variables for the picture beneath have no special meaning in a mask. A mask can read eight distinct inputs. An adjustment can also read eight, counted across its active channel expressions together. Repeating an input uses one place.
Write numbers, operators and named values
Enter decimal numbers such as 2, 0.35 or .5. Scientific notation such as 1e-3 means 0.001. Names are case-insensitive. Start a name with a letter or underscore. The rest may include letters, digits, underscores, periods and @, as in red.2. Use the editor’s suggestion to insert the exact role name of an input.
Studio evaluates the following groups from top to bottom. Parentheses override this order. Within a group, binary operators evaluate from left to right, except for powers.
| Operators | Result at this pixel |
|---|---|
+x, -x, ~x, !x | Keep the sign, negate, invert as 1 - x, or test for zero. ~0.25 gives 0.75. !0.25 gives 0. |
a ^ b | Raise a to the power b. Powers group from the right, so 2 ^ 3 ^ 2 gives 512. A leading minus binds first, so -2 ^ 2 gives 4. Write -(2 ^ 2) for −4. |
a * b, a / b | Multiply or divide. Write the multiplication sign explicitly. |
a + b, a - b | Add or subtract. |
<, <=, >, >=, ==, != | Compare two values. Each comparison gives 1 for true and 0 for false. Use == for equality. |
a && b | Give 1 when both values are nonzero. To test an interval, write both comparisons, as in Ha > 0.1 && Ha < 0.8. |
a || b | Give 1 when either value is nonzero. Otherwise give 0. |
Give an intermediate value a name with =. Write the result last. Each assignment ends at a line break or a semicolon. A final semicolon is optional. Choose a distinct name so a local value cannot hide an input you need later. A later assignment can update a local value. Function names are reserved.
overlap = Ha * OIII
weight = overlap ^ ~overlap
weight * Ha + ~weight * OIII
Here overlap is the product of the two inputs at one pixel. The final line blends between H-alpha and oxygen using the local weight. Each new pixel gets its own values. If Studio reports that an expression is too deep, give a nested calculation a name. Each expression allows 256 compiled instructions and space for 32 simultaneous values, including local names.
Look up a function
Use parentheses and separate arguments with commas. Each argument can be a number, an input or another expression. The examples use numbers you can replace with pixel values. All functions work at one pixel. For example, mean(r, g, b) averages three channels at that position.
Combine or select values
| Function | Arguments and result |
|---|---|
min(a, …) | The smallest of one or more values. min(0.2, 0.8) gives 0.2. |
max(a, …) | The largest of one or more values. max(0.2, 0.8) gives 0.8. |
sum(a, …) | The sum of one or more values. sum(0.4, 0.8) gives 1.2, above SDR white. |
mean(a, …) | The arithmetic mean of one or more values. mean(0.2, 0.5, 0.8) gives 0.5. |
avg(a, …) | An alias for mean with the same arguments. avg(0.2, 0.8) gives 0.5. |
iif(condition, yes, no) | Select yes when the condition is nonzero or no when it is zero. iif(0.3 > 0.2, 1, 0) gives 1. All three arguments are evaluated. |
Control range and contrast
| Function | Arguments and result |
|---|---|
range(x, low, high) | Hold x between the limits. range(0.8, 0.1, 0.6) gives 0.6. Values inside stay where they are. Put the lower bound first. With reversed bounds the result is high. |
rescale(x, low, high) | Map low to 0 and high to 1, with linear interpolation and clipping to that interval. rescale(0.3, 0.1, 0.5) gives 0.5. Reversing the bounds reverses the ramp. Equal bounds give 0. |
mtf(m, x) | Midtones transfer. Choose a midtone m between 0 and 1 to map it to 0.5. mtf(0.25, 0.25) gives 0.5. Values of x at or below 0 give 0, and values at or above 1 give 1. Choose m below 0.5 to brighten midtones or above 0.5 to darken them. |
Powers, roots and logarithms
| Function | Arguments and result |
|---|---|
abs(x) | Magnitude of x. abs(-0.2) gives 0.2. Use it on a difference to see the size of a change in either direction. |
sqrt(x) | Square root. Use a nonnegative argument. sqrt(0.25) gives 0.5. |
pow(x, y) | Raise base x to exponent y, equivalent to x ^ y. pow(0.5, 2) gives 0.25. Use a nonnegative base for fractional powers. |
exp(x) | Raise the natural base e to x. exp(0) gives 1. |
ln(x) | Natural logarithm of a positive value. ln(1) gives 0. |
log(x) | Base-10 logarithm of a positive value. log(100) gives 2. |
log2(x) | Base-2 logarithm of a positive value. log2(8) gives 3. A doubling adds 1 to this result. |
Keep or fit the result
As computed passes the adjustment’s result on to the layers above it. In SDR, 1 is white. In HDR, a result above 1 can use the available headroom. In a stretched picture, a neutral result of about 1.35 corresponds to twice the light of SDR white. Compare pixel values and stops of headroom. Use Clipping in Final picture to check the finished output. A function such as mtf that caps its own output at 1 will already have discarded values above white.
Choose Rescale under Result to fit out-of-range colors into the picture. Studio measures the lowest and highest values across all three channels at full resolution in the area the inputs cover together. Studio measures the expression at full opacity before this layer’s mask and uses one linear scale for all three channels. In SDR, if the minimum is 0.1 and the maximum is 2, Studio halves the values, including the minimum. If the result already fits between black and the picture’s peak, it stays as computed. Edits to the layer or the picture beneath trigger a new measurement. The canvas shows the unscaled result until the measurement finishes.
t * 2 in both views of the starless Iris group. In SDR, the doubled core reaches white. After Studio measures the full picture, Rescale brings the peak back into range. In this crop the median red value falls from 0.562 to 0.268.The rescale(x, low, high) function uses the two bounds you supply at each pixel. Use it when a particular input brightness should always map to a particular amount of coverage. A computed mask always limits its expression result to 0–1 before applying Reach, Smoothing and touch-ups. With Strong selected on the layer, white applies the layer fully, gray partly and black leaves it out. Weak reverses that coverage.
Calculations use floating-point values. A final result that is NaN, for example from sqrt(-1), becomes 0. Division by zero or a log of zero can produce an infinite value. Keep denominators away from zero and logs positive. For a nonnegative input such as oxygen, Ha / max(OIII, 0.01) limits the denominator to at least 0.01. The ratio may still exceed 1.
Start with a template
Select a Pixel math adjustment. Under Templates, click a name to apply it. Studio selects One for RGB or Split and replaces the expressions in that mode. Hover over a button for its description.
Jump to a template
Each pair follows the same document pixels through one adjustment at full opacity. You can try any template independently. On Iris, the adjustment sits in the starless Color group below the returned stars.
Exposure
Increase every stretched channel by a factor of about 1.41. Change 0.5 to set the exponent.
One for RGB t * 2 ^ 0.5
Midtones
A channel value of 0.4 moves to 0.5. Move the first argument toward 0.5 for a gentler lift.
One for RGB mtf(0.4, t)
Contrast curve
This S curve darkens values below 0.5 and brightens values above 0.5. The first assignment limits the input to 0–1.
One for RGB x = range(t, 0, 1); iif(x < 0.5, 2 * x ^ 2, 1 - 2 * (1 - x) ^ 2)
Saturation
Each channel moves away from the working-space luminance. Use a factor of 1 to keep the incoming color or 0 for gray.
One for RGB max(l + (t - l) * 1.4, 0)
White balance
Raise red by 10%, keep green and lower blue by 10%. Adjust the gains to suit the cast you see.
- Red
r * 1.1- Green
g- Blue
b * 0.9
Green reduction
Cap green at whichever is brighter, red or blue. Red and blue pass through.
- Red
r- Green
min(g, max(r, b))- Blue
b
Invert
Subtract each channel from 1. Black and SDR white exchange places.
One for RGB ~t
Foraxx, SHO
Requires SII, Ha and OIII. Oxygen sets the red mix between sulfur and hydrogen. The overlap between hydrogen and oxygen sets the green mix. Blue comes from oxygen.
- Red
m = OIII ^ ~OIII; m * SII + ~m * Ha- Green
p = Ha * OIII; m = p ^ ~p; m * Ha + ~m * OIII- Blue
OIII
Foraxx, HOO
Requires Ha and OIII. Red comes from hydrogen and blue from oxygen. Where both lines are strong, more hydrogen contributes to green.
- Red
Ha- Green
p = Ha * OIII; m = p ^ ~p; m * Ha + ~m * OIII- Blue
OIII
Ha into red
Requires Ha. Only the red expression changes. A pixel takes the brighter of broadband red and stretched H-alpha.
- Red
max(r, Ha)- Green
g- Blue
b
OIII into green and blue
Requires OIII. Compare oxygen independently with green and blue and keep the brighter value in each. Red passes through.
- Red
r- Green
max(g, OIII)- Blue
max(b, OIII)
Work through three edits
Lift faint RGB nebulosity
On an SDR RGB composition such as the Iris Nebula, choose One for RGB and enter mtf(0.4, t). A channel value of 0.4 moves to 0.5 while black and white stay fixed. This gives the dust more separation from a dark background. Compare the dust with an adjacent dark pocket. If the pocket brightens too much, move 0.4 toward 0.5 or lower the layer’s opacity. If you separated stars, put the adjustment above the starless picture and below the returned stars to preserve their existing stretch.
mtf(0.4, t). The fold brightens enough to trace toward the core. The dark pocket also lifts slightly. If it starts competing with the dust, reduce the lift.Add H-alpha to broadband red
With a broadband picture and a stretched H-alpha input, choose Split. Enter max(r, Ha) for Red, g for Green and b for Blue. At a pixel with red 0.30 and H-alpha 0.55, red becomes 0.55. Where H-alpha is weaker, the broadband red passes through. Compare the nebula with nearby sky. If both turn red, review the H-alpha background and stretch before raising its contribution.
Limit an adjustment to oxygen emission
In a narrowband document with OIII, select the adjustment you want to limit. Choose New mask for this layer and enter rescale(OIII, 0.1, 0.5) in the mask’s Pixel math field. Choose Mask to inspect it. An oxygen value of 0.1 gives black, 0.3 gives half coverage and 0.5 gives white. The gradual transition lets a color adjustment follow a filament without a hard edge. These bounds are starting values. Raise the low bound if the sky appears gray, or lower the high bound if the filament receives too little of the adjustment.
Choose Picture and compare the filament and the surrounding background. An edit to the oxygen input’s stretch also changes this mask. Adjust Reach to extend coverage into fainter signal and Smoothing to soften visible speckle. Choosing another Shape or changing the mask’s input shortcuts replaces its custom expression.
mtf(0.25, t) in One for RGB. White and gray in the oxygen mask let it brighten the strand. The black mask at the sky mark keeps the sky at its previous level.



























