All duties (picture processing[1]) may 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 below are Three targets / duties:

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

Graphic file[edit]

Graphic recordsdata

Reminiscence array[edit]

Picture in reminiscence is a matrix:

  • A 24-bit coloration picture is an (Width x Peak x 3) matrix.
  • Grey-level and black-and-white pictures are of dimension (Width x Peak).

The colour depth of the picture:

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

Display screen pixels[edit]

glxinfo | grep "direct rendering"


Direct Rendering Infrastructure (DRI2)[10]

Instance of fascinating coloration gradient

Palette graphics, palette substitute mechanism

Subject strains[edit]

Subject line[11]


Tracing curve[12]


  • basic, (analytic or systematic) = curve sketching[13]
  • native methodology

Three Curve Tracing Fashions[14]

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




Curve rasterisation[edit]


Ray may be parametrised with radius (r)

Closed curve[edit]

Easy closed curve (“a linked curve that doesn’t cross itself and ends on the identical level the place it begins”[16] = having no endpoints) may 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 solely 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 coloration of examined pixel.

One can even approximate consequence by sum of two magnitudes:

which is far quicker to compute.[22]


  • select pixel and its 3×3 neighberhood A
  • compute Sobel filter for horizontal Gh and vertical strains Gv
  • compute Sobel filter G
  • compute coloration 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 knowledge. To seek out borders on this picture merely do:

     Gv= - knowledge[iY-1][iX-1] - 2*knowledge[iY-1][iX] - knowledge[iY-1][iX+1] + knowledge[iY+1][iX-1] + 2*knowledge[iY+1][iX] + knowledge[iY+1][iX+1];
     Gh= - knowledge[iY+1][iX-1] + knowledge[iY-1][iX+1] - 2*knowledge[iY][iX-1] + 2*knowledge[iY][iX+1] - knowledge[iY-1][iX-1] + knowledge[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 dimension).

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

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

to have new picture with marked borders.

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

Different implementations:


Unhealthy edge place seen in the course of picture. Traces usually are not assembly in good factors, like z = 0

Edge place:

In ImageMagick as “you may see, the sting is added solely to areas with a coloration gradient that’s greater than 50% white! I do not know if this can be a bug or intentional, nevertheless it signifies that the sting within the above is situated nearly utterly within the white components of the unique masks picture. This reality may be extraordinarily necessary 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 strains, producing a bizarre consequence.”[24]
  • strains usually are not 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 through PIL operate resize[41]
  • Java code by Josef Jelinek:[42] supersampling with grid algorithm, computes Four new factors (corners), ensuing coloration is an avarage of every coloration part:
 //Created by Josef Jelinek
 // http://java.rubikscube.information/
 Coloration c0 = coloration(dx, dy); // coloration of central level
 // computation of Four new factors for antialiasing
 if (antialias) { // computes Four new factors (corners)
   Coloration c1 = coloration(dx - 0.25 * r, dy - 0.25 * r);
   Coloration c2 = coloration(dx + 0.25 * r, dy - 0.25 * r);
   Coloration c3 = coloration(dx + 0.25 * r, dy + 0.25 * r);
   Coloration c4 = coloration(dx - 0.25 * r, dy + 0.25 * r);
  // ensuing coloration; every part of coloration is an avarage of 5 values (central level and Four corners)
   int crimson = (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;
   coloration = new Coloration(crimson, 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.internet/
  5. http://freeimage.sourceforge.internet/
  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 slightly 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. Pictures of Julia units that you could belief Luiz Henrique de Figueiredo
  31. “Pictures of Julia units that you could belief” by Luiz Henrique de Figueiredo and Joao Batista Oliveira
  32. adaptive algorithms for producing assured pictures 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 greatest to do it?
  37. Supersampling at wikipedia
  38. ImageMagick v6 Examples — Resampling Filters
  39. What’s the greatest 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 exhibiting gamma-correct downscale of dense a part of Mandelbrot set

Leave a Reply

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