All duties (picture processing[1]) might be achieved utilizing:

  • personal applications (GUI or console)
  • personal applications and graphic libraries
  • graphic applications like GIMP
  • fractal applications like:

One can use free graphic libraries:

Listed here are Three targets / duties:

  • graphic file (saving/ loading picture)
  • reminiscence array (processing picture)
  • display screen pixels (displaying picture)

Graphic file[edit]

Graphic recordsdata

Reminiscence array[edit]

Picture in reminiscence is a matrix:

  • A 24-bit colour picture is an (Width x Peak x 3) matrix.
  • Grey-level and black-and-white photos are of measurement (Width x Peak).

The colour depth of the picture:

  • 8-bit for grey
  • 24 or 32-bit for colour,
  • 1-bit for black and white.

Display pixels[edit]

glxinfo | grep "direct rendering"


Direct Rendering Infrastructure (DRI2)[10]

Instance of fascinating colour gradient

Palette graphics, palette alternative mechanism

Subject traces[edit]

Subject line[11]


Tracing curve[12]


  • normal, (analytic or systematic) = curve sketching[13]
  • native technique

Three Curve Tracing Fashions[14]

  • Pixel-by-Pixel tracing
  • The bipartite receptive discipline operator
  • The zoom lens operator




Curve rasterisation[edit]


Ray might be parametrised with radius (r)

Closed curve[edit]

Easy closed curve (“a related curve that doesn’t cross itself and ends on the identical level the place it begins”[16] = having no endpoints) might be parametrized with angle (t).

Edge detection[edit]

Sobel filter[edit]

Brief introduction[edit]

Sobel filter G consist of two filters (masks):

  • Gh for horizontal adjustments.
  • Gv for vertical adjustments.
Sobel kernels[edit]

8-point neighborhood on a 2D grid

The Sobel kernel accommodates weights for every pixel from the 8-point neighbourhood of a examined pixel. These are 3×3 kernels.

There are 2 Sobel kernels, one for computing horizontal adjustments and different for computing vertical adjustments. Discover that a big horizontal change could point out a vertical border, and a big vertical change could point out a horizontal border. The x-coordinate is right here outlined as rising within the “proper”-direction, and the y-coordinate is outlined as rising within the “down”-direction.

The Sobel kernel for computing horizontal adjustments is:

The Sobel kernel for computing vertical adjustments is:

Observe that:

  • sum of weights of kernels are zero

i=19Hi=0{displaystyle sum _{i=1}^{9}H_{i}=0}

i=19Vi=0{displaystyle sum _{i=1}^{9}V_{i}=0}

  • One kernel is just the opposite rotated by 90 levels.[18]
  • Three weights in every kernal are zero.
Pixel kernel[edit]

Pixel kernel A containing central pixel

A5{displaystyle A_{5}}

with its 3×3 neighbourhood:

Different notations for pixel kernel:

the place:[19]

unsigned char ul, // higher left
unsigned char um, // higher center
unsigned char ur, // higher proper
unsigned char ml, // center left
unsigned char mm, // center = central pixel
unsigned char mr, // center proper
unsigned char ll, // decrease left
unsigned char lm, // decrease center
unsigned char lr, // decrease proper

Pixel 3×3 neighbourhood (with Y axis directed down)

In array notation it’s:[20]

In geographic notation usede in mobile aotomats it’s central pixel of Moore neighbourhood.

So central (examined) pixel is:

A5=mm=A[x][y]{displaystyle A_{5}=mm=A[x][y],}

Sobel filters[edit]

Compute Sobel filters (the place

{displaystyle *}

right here denotes the 2-dimensional convolution operation not matrix multiplication). It’s a sum of merchandise of pixel and its weights:

As a result of Three weights in every kernal are zero so there are solely 6 merchandise.[21]

quick Gh = ur + 2*mr + lr - ul - 2*ml - ll;
quick Gv = ul + 2*um + ur - ll - 2*lm - lr;

Result’s computed (magnitude of gradient):

It’s a colour of examined pixel.

One can even approximate end result by sum of two magnitudes:

which is way quicker to compute.[22]


  • select pixel and its 3×3 neighberhood A
  • compute Sobel filter for horizontal Gh and vertical traces Gv
  • compute Sobel filter G
  • compute colour of pixel


Sobel filters (2 filters 3×3): picture and full c code

Skipped pixel – some factors from its neighbourhood are out of the picture

Lets take array of 8-bit colours (picture) referred to as information. To seek out borders on this picture merely do:

     Gv= - information[iY-1][iX-1] - 2*information[iY-1][iX] - information[iY-1][iX+1] + information[iY+1][iX-1] + 2*information[iY+1][iX] + information[iY+1][iX+1];
     Gh= - information[iY+1][iX-1] + information[iY-1][iX+1] - 2*information[iY][iX-1] + 2*information[iY][iX+1] - information[iY-1][iX-1] + information[iY+1][iX+1];
     G = sqrt(Gh*Gh + Gv*Gv);
     if (G==0) {edge[iY][iX]=255;} /* background */
         else {edge[iY][iX]=0;}  /* boundary */

Observe that right here factors on borders of array (iY= 0, iY = iYmax, iX=0, iX=iXmax) are skipped

Result’s saved to a different array referred to as edge (with the identical measurement).

One can save edge array to file displaying solely borders, or merge 2 arrays:

    for(iX=1;iX<iXmax-1;++iX){ if (edge[iY][iX]==0) information[iY][iX]=0;}}

to have new picture with marked borders.

Above instance is for 8-bit or listed colour. For increased bit colours “the system is utilized to all three colour channels individually” (from RoboRealm doc).

Different implementations:


Dangerous edge place seen in the midst of picture. Strains aren’t assembly in good factors, like z = 0

Edge place:

In ImageMagick as “you may see, the sting is added solely to areas with a colour gradient that’s greater than 50% white! I do not know if this can be a bug or intentional, but it surely signifies that the sting within the above is situated virtually utterly within the white components of the unique masks picture. This reality might be extraordinarily essential when making use of the outcomes of the “-edge” operator.”[23]

The result’s:

  • doubling edges; “in case you are edge detecting a picture containing an black define, the “-edge” operator will ‘twin’ the black traces, producing a bizarre end result.”[24]
  • traces aren’t assembly in good factors.

See additionally new operators from 6 model of ImageMagick: EdgeIn and EdgeOut from Morphology[25]

Edge thickening[edit]


convert $tmp0 -convolve "1,1,1,1,1,1,1,1,1" -threshold 0 $outfile

Filling contour – easy process in c

Interval arithmetic[edit]


Aliased chessboard – picture and c src code


instance of supersampled picture

Cpp code of supersampling

Different names:

  • antigrain geometry
  • Supersampling (downsampling)[37][38]
  • downsizing
  • downscaling[39]
  • subpixel accuracy


 // subpixels completed -> make arithmetic imply
 char pixel[3];
 for (int c = 0; c < 3; c++)
   pixel[c] = (int)(255.0 * sum[c] / (subpix * subpix)  + 0.5);
 fwrite(pixel, 1, 3, image_file);
 //pixel completed
  • command line model of Aptus (python and c code) by Ned Batchelder[40] (see is utilizing a high-quality downsampling filter via PIL operate resize[41]
  • Java code by Josef Jelinek:[42] supersampling with grid algorithm, computes Four new factors (corners), ensuing colour is an avarage of every colour element:
 //Created by Josef Jelinek
 // http://java.rubikscube.information/
 Colour c0 = colour(dx, dy); // colour of central level
 // computation of Four new factors for antialiasing
 if (antialias) { // computes Four new factors (corners)
   Colour c1 = colour(dx - 0.25 * r, dy - 0.25 * r);
   Colour c2 = colour(dx + 0.25 * r, dy - 0.25 * r);
   Colour c3 = colour(dx + 0.25 * r, dy + 0.25 * r);
   Colour c4 = colour(dx - 0.25 * r, dy + 0.25 * r);
  // ensuing colour; every element of colour is an avarage of 5 values (central level and Four corners)
   int purple = (c0.getRed() + c1.getRed() + c2.getRed() + c3.getRed() + c4.getRed()) / 5;
   int inexperienced = (c0.getGreen() + c1.getGreen() + c2.getGreen() + c3.getGreen() + c4.getGreen()) / 5;
   int blue = (c0.getBlue() + c1.getBlue() + c2.getBlue() + c3.getBlue() + c4.getBlue()) / 5;
   colour = new Colour(purple, inexperienced, blue);
  • one could make huge picture (like 10 000 x 10 000) and convert/resize it (downsize). For instance utilizing ImageMagick:
convert huge.ppm -resize 2000x2000 m.png

See additionally:

Description is right here.

Optimisation is described right here

  1. IPOL Journal · Picture Processing On Line
  2. ImageMagick picture processing libraries
  3. GEGL (Generic Graphics Library)
  4. http://openil.sourceforge.web/
  5. http://freeimage.sourceforge.web/
  6. GD Graphics Library
  7. GraphicsMagick
  8. OpenCv
  9. OpenImageIO
  10. w:Direct Rendering Infrastructure (DRI)
  11. wikipedia: Subject line
  12. Curve sketching in wikipedia
  14. Predicting the form of distance capabilities in curve tracing: Proof for a zoom lens operator by PETER A. McCORMICK and PIERRE JOLICOEUR
  15. stackoverflow query: line-tracking-with-matlab
  16. mathwords: simple_closed_curve
  17. matrixlab – line-detection
  18. Sobel Edge Detector by R. Fisher, S. Perkins, A. Walker and E. Wolfart.
  19. NVIDIA Boards, CUDA GPU Computing dialogue by kr1_karin
  20. Sobel Edge by RoboRealm
  21. nvidia discussion board: Sobel Filter Do not perceive a little bit factor within the SDK instance
  22. Sobel Edge Detector by R. Fisher, S. Perkins, A. Walker and E. Wolfart.
  23. ImageMagick doc
  24. Edge operator from ImageMagick docs
  25. ImageMagick doc: morphology / EdgeIn
  26. dilation at HIPR2 by Robert Fisher, Simon Perkins, Ashley Walker, Erik Wolfart
  27. ImageMagick doc: morphology, dilate
  28. Fred’s ImageMagick Scripts
  29. Photographs of Julia units you could belief Luiz Henrique de Figueiredo
  31. “Photographs of Julia units you could belief” by Luiz Henrique de Figueiredo and Joao Batista Oliveira
  32. adaptive algorithms for producing assured photos of Julia units by Luiz Henrique de Figueiredo
  33. Drawing Fractals With Interval Arithmetic – Half 1 by Dr Rupert Rawnsley
  34. Drawing Fractals With Interval Arithmetic – Half 2 by Dr Rupert Rawnsley
  35. Spatial anti aliasing at wikipedia
  36. fractalforums dialogue: Antialiasing fractals – how finest to do it?
  37. Supersampling at wikipedia
  38. ImageMagick v6 Examples — Resampling Filters
  39. What’s the finest picture downscaling algorithm (quality-wise)?
  40. Aptus (python and c code) by Ned Batchelder
  41. Pil operate resize
  42. Java code by Josef Jelinek
  43. ImageMagick: resize_gamma
  44. A Cheritat wiki: see picture displaying gamma-correct downscale of dense a part of Mandelbrot set

Leave a Reply

Your email address will not be published. Required fields are marked *