The Formulas Rendering Plug-In for the GIMP 2 version 0.9.8
Released on 14-Nov-2010 at 16:00
Written by Nicolas BENOIT, nbenoit@tuxfamily.org
http://nbenoit.tuxfamily.org

French translation: Nicolas BENOIT
German translation: Dominik SEICHTER


This simple plugin allows you to change the values of each color channel of each pixel of a layer by using mathematical expressions.
It is compatible with RGB* and Gray* layers.

Operator Description
+ addition
- substraction
* multiplication
/ division
^ power
% modulo

 
Function Description Number of arguments
red ( arg1, arg2 ) Red channel value at (arg1,arg2) coordinates two arguments
gray ( arg1, arg2 ) Gray channel value at (arg1,arg2) coordinates two arguments
green ( arg1, arg2 ) Green channel value at (arg1,arg2) coordinates two arguments
blue ( arg1, arg2 ) Blue channel value at (arg1,arg2) coordinates two arguments
alpha ( arg1, arg2 ) Alpha channel value at (arg1,arg2) coordinates two arguments
rgb ( arg1, arg2 ) Currently processed channel value at (arg1,arg2) coordinates two arguments
rand ( ) random value between 0.0 and 1.0 no argument
sin ( arg ) sine function one argument
sinh ( arg ) hyperbolic sine function one argument
asin ( arg ) arc sine function one argument
asinh( arg ) arc hyperbolic sine function one argument
cos ( arg ) cosine function one argument
cosh ( arg ) hyperbolic cosine function one argument
acos ( arg ) arc cosine function one argument
acosh ( arg ) arc hyperbolic cosine function one argument
tan ( arg ) tangent function one argument
tanh ( arg ) hyperbolic tangent function one argument
atan ( arg ) arc tangent function one argument
atan2 ( arg1, arg2 ) arc tangent function returning the correct quadrant two arguments
atanh ( arg ) arc hyperbolic tangent function one argument
rad ( arg ) to radians conversion one argument
deg ( arg ) to degrees conversion one argument
sqrt ( arg ) square root function one argument
cbrt ( arg ) cube root function one argument
log ( arg ) natural logarithmic function one argument
log2 ( arg ) base-2 logarithmic function one argument
log10 ( arg ) base-10 logarithmic function one argument
exp ( arg ) base-e exponential function one argument
abs ( arg ) absolute value one argument
sign ( arg ) sign of the value one argument
ceil ( arg ) smallest integral value not less than argument one argument
round ( arg ) round to nearest integer, away from zero one argument
min ( arg1, arg2, ..., argn ) minimal value one or more arguments
max ( arg1, arg2, ..., argn ) maximal value one or more arguments
avg ( arg1, arg2, ..., argn ) average value one or more arguments

 
Value Description
pi pi constant
e e constant
j gold number
w width of the image
h height of the image
x x of the cartesian coordinate of the current pixel
y y of the cartesian coordinate of the current pixel
r r of the polar coordinate of the current pixel
t t of the polar coordinate of the current pixel

 

The plugin's dialog

As you can see on the screenshot above, the interface of the plug-in is pretty simple.
You just have to enter the formulas inside the text fields...
Always keep in mind that the result of a formula must be between 0 and 255.

A Sobel edge detection filter

Here is another screenshot with an edge detection formula (Sobel filter) applied to a black G-clef on a white background.


Here are a few examples:

Red Channel Green Channel Blue Channel
1 100 (1+cos(rad(x*2.21*x/(y+1))))*92 (1+sin(rad(x*2.21*x/(y+1))))*127
2 sqrt((rgb(x+1,y-1)+2*rgb(x+1,y)+rgb(x+1,y+1)-rgb(x-1,y-1)-2*rgb(x-1,y)-rgb(x-1,y+1))^2+((rgb(x-1,y+1)+2*rgb(x,y+1)+rgb(x+1,y+1)-rgb(x-1,y-1)-2*rgb(x-1,y)-rgb(x-1,y+1))^2))*(255/1442.5) sqrt((rgb(x+1,y-1)+2*rgb(x+1,y)+rgb(x+1,y+1)-rgb(x-1,y-1)-2*rgb(x-1,y)-rgb(x-1,y+1))^2+((rgb(x-1,y+1)+2*rgb(x,y+1)+rgb(x+1,y+1)-rgb(x-1,y-1)-2*rgb(x-1,y)-rgb(x-1,y+1))^2))*(255/1442.5) sqrt((rgb(x+1,y-1)+2*rgb(x+1,y)+rgb(x+1,y+1)-rgb(x-1,y-1)-2*rgb(x-1,y)-rgb(x-1,y+1))^2+((rgb(x-1,y+1)+2*rgb(x,y+1)+rgb(x+1,y+1)-rgb(x-1,y-1)-2*rgb(x-1,y)-rgb(x-1,y+1))^2))*(255/1442.5)
3 ((1+cos(rad(x+y)))*127)+1 ((1+sin(rad(x+y)))*127)+1 y%255
4 (1+sin(x/(w/pi)))*127 (1+sin(y/(w/pi)))*127 255
5 (sin(r)+1)*127 (sin(r)+1)*64 (sin(r+pi)+1)*127