# Fractals/Iterations in the complex plane/equipotetential

Boundary tracing, also known as contour tracing, of a binary digital region can be thought of as a segmentation technique that identifies the boundary pixels of the digital region. Boundary tracing is an important first step in the analysis of that region. Boundary is a topological notion. However, a digital image is no topological space. Therefore, it is impossible to define the notion of a boundary in a digital image mathematically exactly. Most publications about tracing the boundary of a subset S of a digital image I describe algorithms which find a set of pixels belonging to S and having in their direct neighborhood pixels belonging both to S and to its complement I - S. According to this definition the boundary of a subset S is different from the boundary of the complement I – S which is a topological paradox. To define the boundary correctly it is necessary to introduce a topological space corresponding to the given digital image. Such space can be a two-dimensional abstract cell complex. It contains cells of three dimensions: the two-dimensional cells corresponding to pixels of the digital image, the one-dimensional cells or “cracks” representing short lines lying between two adjacent pixels, and the zero-dimensional cells or “points” corresponding to the corners of pixels. The boundary of a subset S is then a sequence of cracks and points while the neighborhoods of these cracks and points intersect both the subset S and its complement I – S. The boundary defined in this way corresponds exactly to the topological definition and corresponds also to our intuitive imagination of a boundary because the boundary of S should contain neither elements of S nor those of its complement. It should contain only elements lying between S and the complement. This are exactly the cracks and points of the complex. This method of tracing boundaries is described in the book of Vladimir A. Kovalevsky and in the web site.

# images

* Internal and external LCM
* period 1
* period 1, cubic map
* period 2
* period 2 with inversed plane
* period 3
* Divide and conquere

# Dictionary

* potential
** scalar potential
** complex potential
* Contour line, isoline in wikipedia
* equipotential
* tracing
* contour plotting algorithm

# Application

* boundary tracing
* shape of the function f = shape of the critical level curves (level curves containing critical points of f)

# Algorithms

Algorithms used for boundary tracing:
* Square tracing algorithm
* Moore-neighbor tracing algorithm
* Radial sweep
* Theo Pavlidis’ algorithm
* A generic approach using vector algebra for tracing of a boundary can be found at.
* An extension of boundary tracing for segmentation of traced boundary into open and closed sub-section is described at.
* edge detection of level sets boundaries: Level Set Method (LSM) + edge detection ( for example Sobel filter)
* tracing equilevel curves ( isocurves)
* inverse iteration of closed curve ( circle) around attractor

## Input

* function f(x,y)
** math equation ( for symbolic computations)
** program subroutine ( for numerical computations)
* plane
** matrix of floating-point values ( scalar field ) ( for numerical computations)

## Moore-neighbor tracing algorithm

In cellular automata, the Moore neighborhood is defined on a two-dimensional square lattice and is composed of a central cell and the eight cells that surround it.
The neighborhood is named after Edward F. Moore, a pioneer of cellular automata theory.

### Importance

It is one of the two most commonly used neighborhood types, the other one being the von Neumann neighborhood, which excludes the corner cells. The well known Conway's Game of Life, for example, uses the Moore neighborhood. It is similar to the notion of 8-connected pixels in computer graphics.
The Moore neighbourhood of a cell is the cell itself and the cells at a Chebyshev distance of 1.
The concept can be extended to higher dimensions, for example forming a 26-cell cubic neighborhood for a cellular automaton in three dimensions, as used by 3D Life. In dimension d, where $0\leq d,d\in \mathbb {Z}$, the size of the neighborhood is 3$^d$ − 1.
In two dimensions, the number of cells in an extended Moore neighbourhood, given its range r is (2r + 1)$^2$.

### Algorithm

The idea behind the formulation of Moore neighborhood is to find the contour of a given graph. This idea was a great challenge for most analysts of the 18th century, and as a result an algorithm was derived from the Moore graph which was later called the Moore Neighborhood algorithm.
The pseudocode for the Moore-Neighbor tracing algorithm is

### Termination condition

The original termination condition was to stop after visiting the start pixel for the second time. This limits the set of contours the algorithm will walk completely. An improved stopping condition proposed by Jacob Eliosoff is to stop after entering the start pixel for the second time in the same direction you originally entered it.

## tracing by David Rand

Description by David Rand

## Square tracing algorithm

The square tracing algorithm is simple, yet effective. Its behavior is completely based on whether one is on a black, or a white cell (assuming white cells are part of the shape). First, scan from the upper left to right and row by row. Upon entering your first white cell, the core of the algorithm starts. It consists mainly of two rules:
* If you are in a white cell, go left.
* If you are in a black cell, go right.
Keep in mind that it matters how you entered the current cell, so that left and right can be defined.

# Test values

* on the parameter plane
** c = -0.752174630125934 +0.057670473174377*i. Potential = 2.108396223015232e-16
** c = -0.750087705298239 +0.014275963195317 *i, ( Mandel can not draw such equipotential line)

# Programs

* otis by Tomoki Kawahira
* mandel by Wolf Jung
* ofxContourPlot by Eva Schindling- contour-plotting of mathematical functions f(x,y)
* xd3d
* Fractal zoomer

# Code

* C++ code from Mandel by Wolf Jung
* Contour tracing library : A 2D library to trace contours. by STPR.
* Implementation of the paper "Topological Structural Analysis of Digitized Binary Images by Border Following" using C language
* A-C-implementation-of-an-improved-contour-plotting ( c++)
* contour lines
** in Maxima CAS
* conplot in Fortran
* Paul Bourke: conrec
* c code
* d3 - js library
* Implementation of an Improved Contour Plotting Algorithm August 1981 Thesis by Michael Faiman

## Lisp

Lisp code from Maxima CAS
Function ploteq
plots equipotential curves for exp, which should be an expression depending on two variables. The curves are obtained by integrating the differential equation that define the orthogonal trajectories to the solutions of the autonomous system obtained from the gradient of the expression given. The plot can also show the integral curves for that gradient system (option fieldlines).
This program also requires Xmaxima, even if its run from a Maxima session in a console, since the plot will be created by the Tk scripts in Xmaxima. By default, the plot region will be empty until the user clicks in a point (or gives its coordinate with in the set-up menu or via the trajectory_at option).
Most options accepted by plotdf can also be used for ploteq and the plot interface is the same that was described in plotdf.
Example:
Clicking on a point will plot the equipotential curve that passes by that point (in red) and the orthogonal trajectory (in blue).
source code files:
* share/dynamics/dynamics.mac
* share/diffequations/drawdf.mac
* share/dynamics/plotdf.lisp

# References

* ↑ Kovalevsky, V., Image Processing with Cellular Topology, Springer 2021, ISBN 978-981-16-5771-9
* ↑ http://www.kovalevsky.de, Lecture "Tracing Boundaries in 2D Images"
* ↑ mathoverflow.net question: what-are-the-shapes-of-rational-functions ?
* ↑ Contour Tracing Algorithms
* ↑ Abeer George Ghuneim: square tracing algorithm
* ↑ Abeer George Ghuneim: The Radial Sweep algorithm
* ↑ Abeer George Ghuneim: Theo Pavlidis' Algorithm
* ↑ Vector Algebra Based Tracing of External and Internal Boundary of an Object in Binary Images, Journal of Advances in Engineering Science Volume 3 Issue 1, January–June 2010, PP 57–70
* ↑ Graph theory based segmentation of traced boundary into open and closed sub-sections, Computer Vision and Image Understanding, Volume 115, Issue 11, November 2011, pages 1552–1558
* ↑ Contour Plotting In Java by David Rand
* ↑ stackoverflow questions: methods-for-implementing-contour-plotting
* ↑ ContourPlottinginJava by D Rand
* ↑ Solving ... by Josef Boehm and Leon Magiera
* math.stackexchange question : equipotential-curves-of-a-julia-set
* d3-contour