Escape Time
For \( z_0 = 0 \) and all \( c \), the values \( z_n \) are iteratively computed according to the formula: \[ z_{n+1} = z_n^2 + c. \] The sequence is monitored to determine whether it remains bounded or escapes to infinity, based on a divergence radius \( r \), typically set to \( r = 2 \). If \( |z_n| > r \), the sequence is considered divergent. The result is expressed either as the number of iterations required for escape (referred to as the "escape time") or the maximum allowed number of iterations if the point does not escape. Points that do not escape form the Mandelbrot set.
To optimize the computation, a pre-check is performed to determine whether the point \( c = x + yi \) lies within the main cardioid or the period-2 component. This eliminates the need for iterations for these points. The pre-check is based on the following conditions:
- Main Cardioid: A point lies inside the cardioid if: \[ q \cdot (q + (x - 0.25)) \leq 0.25 \cdot y^2, \] where \( q = (x - 0.25)^2 + y^2 \).
- Period-2 Component: A point lies inside this component if: \[ (x + 1)^2 + y^2 \leq 0.0625. \]
If a point satisfies either of these conditions, it is immediately classified as part of the Mandelbrot set, and no iteration is necessary.
Distance Estimation
The Distance Estimation Method is used to calculate an estimate of the shortest distance between a point outside the Mandelbrot set and the set itself. This approach is based on the Hubbard-Douady potential, a function that measures the "potential" of each point outside the set:
\[ G(c) = \lim_{n \to \infty} \frac{\ln |z_n|}{2^n}, \]where \( z_n \) is obtained by iterating the equation \( z_{n+1} = z_n^2 + c \), starting from \( z_0 = 0 \). This potential increases as the point \( c \) moves further away from the Mandelbrot set.
The estimated distance \( d \) between a point \( c \) and the Mandelbrot set is given by:
\[ d = \frac{G(c)}{|G'(c)|}, \]where \( |G'(c)| \) is the magnitude of the derivative of the potential \( G(c) \).
To compute \( G'(c) \), we calculate the derivative \( z'_n \) of the iterated sequence with respect to \( c \). Differentiating the iteration formula \( z_{n+1} = z_n^2 + c \) gives:
\[ z'_{n+1} = 2z_n z'_n + 1, \]with the initial condition \( z'_0 = 1 \). During the iteration process, both \( z_n \) and \( z'_n \) are updated, and their magnitudes are used to estimate the distance:
\[ d = \frac{|z_n| \ln |z_n|}{|z'_n|}. \]Edge Detection
The edge detection algorithm is implemented in two stages. First, we use the classic iteration method to determine how many iterations are required for a point to escape the predefined escape radius. Then, the Sobel filter is applied for edge detection. The filter uses two convolution matrices to calculate the gradient in both the horizontal and vertical directions:
For the horizontal direction:
\[ \text{sobelX} = \begin{bmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \end{bmatrix} \]For the vertical direction:
\[ \text{sobelY} = \begin{bmatrix} -1 & -2 & -1 \\ 0 & 0 & 0 \\ 1 & 2 & 1 \end{bmatrix} \] The method identifies areas where there are significant changes, indicating the presence of edges. The method works by examining the differences in intensity between neighboring points in horizontal and vertical directions, which reveals the rate of change in these areas.The algorithm computes the gradient at each point by combining the horizontal and vertical rates of change. If the gradient exceeds a chosen threshold, the point is classified as part of an edge and is marked in black. Otherwise, it is considered part of the background and marked in white.
The result is a high-contrast image that highlights the edges of the Mandelbrot or Julia sets in black, with the rest of the image as a white background.
Rectangle Checking
The Rectangle Checking method is an optimization technique designed to improve the efficiency of fractal calculations by reducing the number of points that need to be processed. Instead of iterating over all points in an image, this method divides the image into rectangles and checks whether all points on the rectangle's boundaries have the same number of iterations \( k \). If they do, it is assumed that all points inside the rectangle share the same iteration count, and the rectangle is filled with a corresponding color.
Key Steps of the Method:
- Boundary Check: The method calculates the number of iterations for all points along the boundaries of a rectangle. If all boundary points have the same iteration count, the rectangle is marked as homogeneous.
- Recursive Subdivision: If the boundary points do not share the same iteration count, the rectangle is divided into four smaller rectangles. Each smaller rectangle undergoes the same process until the rectangles reach the predefined minimum size.
- Filling Rectangles: Homogeneous rectangles are filled with a single color based on their iteration count. This significantly speeds up the rendering of uniform areas, such as the main cardioid or regions far from the fractal set.
This method accelerates calculations while maintaining the desired level of detail. The user can control the level of granularity by adjusting parameters for the initial rectangle size (determining the maximum size of rectangles) and the minimum rectangle size (defining the smallest rectangles to be processed).
Rendering algorithms for Mandelbrot set
Select one of the rendering algorithms for the Mandelbrot set from the dropdown menu below to explore each algorithm in detail.