Pixel Math
One of the most powerful tools in Siril is the Pixel Math. It allows you to manipulate the pixels of the images using mathematical functions. From simple addition or subtraction, to more advanced functions, like MTF, Pixel Math is a perfect tool for astronomical image processing.
This page aims to describe the tool entirely, to see detailed examples, please refer to the excellent tutorial on the site.
The window is divided into 5 parts.
The first one, including 3 text zones receiving the mathematical formulas. Only the first one is used if you want to produce a monochrome image. Uncheck the Use single RGB/K expression button to produce RGB output.
The second is the variables area with the selection of Functions and Operators. Each variable is an image that must be loaded beforehand with the + button. You can click on the desired function and/or operator to make it appear in the formula entry to make it appear in the formula entry.
The third, the parameters field, allows the user to define parameters that are separated by
,
. For example, if you set parameters with the expressionfactor=0.8, K=0.2
, all the occurences offactor
andK
in the formula above will be replaced by 0.8 and 0.2 respectively.Ha * factor + OIII * K
would therefore evaluate toHa * 0.8 + OIII * 0.2
.The output field is reserved for scaling the image within a given range. One need to expand the frame before using it.
Pixel Math rescale box
Finally, the presets area allows the user to reuse previously saved formulas with the button to the right of the formula areas. One need to expand the frame before using it. Double-click on the formula to copy it to the right entry.
Usage
Name of variables
By default it is possible to load 10 images simultaneously. Each image is given
a variable name starting with I followed by a number from 1 to 10. However, if
the loaded image contains the keyword FILTER
, then the value of the latter
becomes the default variable name. Of course it is always possible to change it
by double clicking on it.
Examples
Let's take a monochrome image of galaxies This is a linear data seen through the autostretch view.
The following expression:
iif(Image>med(Image)+3*noise(Image), 1, 0)
will produce a star mask.
Командная строка Siril
pm "expression" [-rescale [low] [high]]
Functions
There are two types of functions. Those that apply directly to the pixels and those that apply to the entire image (such as the statistics functions).
Function |
Use case |
Definition |
---|---|---|
abs |
abs ( x ) |
Absolute value of x. |
acos |
acos ( x ) |
Арккосинус x. |
acosh |
acosh ( x ) |
Гиперболический арксинус x. |
asin |
asin ( x ) |
Арксинус x. |
asinh |
asinh ( x ) |
Гиперболический арксинус x. |
atan |
atan ( x ) |
Арктангенс x. |
atan2 |
atan2 ( y, x ) |
Арктангенс y/x. |
atanh |
atanh ( x ) |
Гиперболический арктангенс x. |
ceil |
ceil ( x ) |
Round x upwards to the nearest integer. |
cos |
cos ( x ) |
Cosine of x. |
cosh |
cosh ( x ) |
Гиперболический косинус x. |
e |
e |
The constant e=2.718282... |
exp |
exp ( x ) |
Показательная функция. |
fac |
fac( x ) |
Факториал. |
iif |
iif( cond, expr_true, expr_false ) |
Conditional function (or inline if function).
Returns expr_true if cond evaluates to nonzero.
Returns expr_false if cond evaluates to zero.
|
floor |
floor ( x ) |
Наибольшее целое значение меньшее или равное x. |
ln |
ln ( x ) |
Натуральный логарифм x. |
log |
log ( x ) |
Base-10 logarithm of x. |
log10 |
log10 ( x ) |
Base-10 logarithm of x. |
log2 |
log2 ( x ) |
Base-2 logarithm of x. |
max |
max ( x, y ) |
Функция максимума. |
min |
min ( x, y ) |
Функция максимума. |
mtf |
mtf ( m, x ) |
Передаточная функция полутонов (MTF) x для параметра баланса полутонов m в диапазоне [0, 1]. |
ncr |
ncr ( x, y ) |
Функция сочетаний. |
npr |
npr ( x, y ) |
Функция перестановок. |
pi |
pi |
The constant π=3.141592... |
pow |
pow ( x, y ) |
Exponentiation function. |
sign |
sign ( x ) |
Sign of x:
\(+1\) if \(x > 0\)
\(−1\) if \(x < 0\)
\(\;0\) if \(x = 0\).
|
sin |
sin ( x ) |
Sine of x. |
sinh |
sinh ( x ) |
Гиперболический синус x. |
sqrt |
sqrt ( x ) |
Square root of x. |
tan |
tan ( x ) |
Tangent of x. |
tanh |
tanh ( x ) |
Гиперболический тангенс x. |
trunc |
trunc ( x ) |
Усечённая целая часть x. |
Function |
Use case |
Definition |
---|---|---|
adev |
adev ( Image ) |
Среднее абсолютное отклонение изображения. |
bwmv |
bwmv ( Image ) |
Двухвесовая средняя дисперсия изображения. |
height |
height ( Image ) |
Height in pixels of the specified image. |
mad |
mad ( Image ) |
Median absolute deviation of the image. The use of mdev is also possible. |
max |
max ( Image ) |
Максимальное значение пикселей изображения. |
mean |
mean ( Image ) |
Mean of the image. |
med |
med ( Image ) |
Median of the image. The use of median is also possible. |
min |
min ( Image ) |
Минимальное значение пикселей изображения. |
noise |
noise ( Image ) |
Оценка Гауссова шума изображения. |
sdev |
sdev ( Image ) |
Standard deviation of the image. |
width |
width ( Image ) |
Width in pixels of the specified image. |
Operators
Оператор |
Use case |
Definition |
---|---|---|
~ |
~x |
Оператор инверсии пикселя. |
- |
-x |
Унарный оператор минус (смена знака). |
+ |
+x |
Унарный оператор плюс. |
! |
!x |
Logical NOT operator. |
^ |
x ^ y |
Exponentiation operator. |
* |
x * y |
Multiplication operator. |
/ |
x / y |
Division operator. |
% |
x % y |
Оператор модуля. |
+ |
x + y |
Addition operator. |
- |
x - y |
Subtraction operator. |
< |
x < y |
Оператор сравнения МЕНЬШЕ. |
<= |
x <= y |
Less Than Or Equal relational operator. |
> |
x > y |
Оператор сравнения БОЛЬШЕ. |
>= |
x >= y |
Greater Than Or Equal relational operator. |
== |
x == y |
Оператор сравнения РАВЕН. |
!= |
x != y |
Not Equal To relational operator. |
&& |
x && y |
Логический оператор И. |
|| |
x || y |
Logical OR operator. |