I am a 1st year student of the department of Computer Science and
Engineering at Polytehnical University of Bucharest. I have started to use
GIMP 2 years ago. I wrote emboss, blur and sharpen tools in C and then in
Octave. I wrote a program which converts images from Targa(for RGB images
with colour map or without) to PPM(type 3) and back.
I would also suggest to generalize the emboss plug-in by using some
operators such as: Sobel, Robert Cross, Prewitt, Scharr or Costella. In case
of Sobel operator we can set 3 types of normalizing (gradient x,y or
magnitude) all 3 making some new effects.
Code review and algorithm description (GIMP plug-ins):
Function cubism: Initializes the values of alpha and image type, and fills
the image with the background colour, which we get from the drawable
image(current image). After calculating the number of tiles of the asked
rectangle the function randoms the indices and initiates the first
rectangle. For each tile the starting point (x,y),height and with is
randomed between certain limits, depending on the tile saturation and tile
size set by the user. The rotation grad is also randomed. Then for each
polygon it adds the calculated points to the structure for creating the
double perspective, rotates and translates it by adding the starting
points(x,y). It checks if the calculated point is between minimum and
maximum and gets the closest value (CLAMP), and gets the pixel color from
the source. Finally it fills with color the drawable image in the pixels
within the polygon.
fill_poly_color: The colour of a pixel will be calculated by looking at the
backgroung image and the intersection of the polygons.
Firstly calculates the distance between the 2 points of the polygon and
initiates values of vector. By polygon_extent we get the minimum and maximum
position of the pixels. It initiates the the values of the lines which need
to be scanned and for every 2 points in the polynom it calculates the
minimum and maximum of the segment.
For every pixel in the polygon it calculates the colour which will be equal
with the color from the source image which is in the position (x,y). x is
equal with ((size_x-1)/4+min_x. In vals the function keeps if that row was
reached or not. The alpha value of the pixel color is between 0.1 and 0.2,
caculated by the distance between the points in the polygon. Every value we
get from buf which will be equal with the color of the coloumn plus the
color from the position (x,y).
2. Fractal trace
Initialization: source pixel table(guchar **) gets the color values of the
current picture for every column. Destination pixel table gets allocated
Pixel get: In function of the image type the asked pixel gets the values
from source pixel table for RGBA.
Pixel set: The color of a certain (position c,y) is uploaded to destination
pixel table considering also the image type.
Pixel get biliner: Calculates the values of the colors for the asked pixel,
making median of its neighbour. The alpha value is accumulated, for the
other values after accumulating the color*alpha it divides with the
Mandelbrot: While the iteration number is smaller then it calculates the
position of the pixels with the quadratic polynomial. The new pixel position
will be the values calculated on the last iteration.
Filter: For each pixel in the given rectangle the function calculates its
colour value. First it calculates a position of the asked pixel by the
parameters, then iterates it with the mandelbrot function. If the iterated
pixel position is in within the image then its color value is calculated.
Else if the position escaped to infinite then in function of the Outside
type it calculates its value. In case of WRAP the color of the pixel will be
equal with the pixel being at the position (px-px/width,py-py/height).
At last it saves the value of the color in destination pixel table.
It is written almost the same thing for the dialog-preview, the setpixel
function is differing because it considers every picture to be type RGBA.
If the given point lies within the cardioid or in the period-2 buld we can
calculate its color without appealing the mandelbrot function, without
iterating, because it will never escape to infinite. Just have to verify
that: q(q+(x-1/4))<1/4*y^2, where q=(x-1/4)^2+y^2.
Moreover the periodicity checking could also be implemented by using a
little more memory. If by iterating a pixel, that pixel reaches another
pixel which was calculated(iterated) before we know its colour.
The scientific name would be random midpoint displacemant. For a given
rectangle the function divides it in 4 smaller one calculating the values of
each pixel by median.
Plasma: After initialization and random if the asked rectangle is not a
single pixel then it puts a seed pixel in the corners and in the center.
After that, while the size of the rectangle is not 1 it recurse through the
pixels going in further depths.
do_plasma: Calculates the mid-point of the rectangle and in case of depht=-1
(first case) randoms the color values for the corners and the middle of the
If depth is 0 (in case the rectangle has less then 4 pixels) for every case
we get the pixel values from the current image, average it and adds a new
random value for each alpha.
Else it calls the function recursively for the 4 divided rectangles.
This can also be written using for example a perlin noise function and
calculating for each component of c sin(f(x,y)*frequency(c)).
Code review and algorithm descrition(GEGL op):
Algorithm: After calculating the Gaussian matrix with the known function for
a certain radius, we ortonormalize it by dividen each element with the sum
of all elements. Then apply this to the image and calculating the value of
each pixel with weighted median.
Using Gaussian linearly separable property we can divide the process into 2
passes. First a vector is used to blur the image in horizontal or vertical
direction, then another vector is used to blur the image for the remaining
Area Filter base class is used because the color value of every pixel is
calculated with the help of the surrounding pixels (from the pixels of a
fir_gen_convolve_matrix calculates the Gaussian matrix for a certain
radius, and depending on the offset (x or y) fir_ver_blur or fir_hor_blur
calculates the value of each color byte for each color with weighted median.
iir_young_hor_blur (or ver) calculates the values of each new pixel by
calculating for each row (column) its new values. The colour vector blur
stores the calculated color values off the pixels, calculated by weighted
media (vector b is the weight of a color, buf stores the original color of
If there is some problem with code review or anything else please write it
and I will correct it.
Gimp-developer mailing list