Binary Decomposition
Binary Decomposition Method
The binary decomposition method is a specific visualization technique where the goal is to assign a color to each point in the complex plane based on a binary condition. In the case of binary decomposition, only two colors are used, in our case, black and white.
At each point in the complex plane, iterations are performed until either the escape condition is met or the maximum number of iterations \(n_{\text{max}}\) is reached. The escape condition is defined as the point exceeding the radius of divergence \(r\), which corresponds to the point "escaping" to infinity. For better computational speed, the following relation is used:
\[ |z_k|^2 = \operatorname{Re}(z_k)^2 + \operatorname{Im}(z_k)^2 > r^2 \]
where \( \operatorname{Re}(z_k) \) and \( \operatorname{Im}(z_k) \) are the real and imaginary parts of \( z_k \) after the \(k\)-th iteration.
The binary decomposition method assigns pixels only two colors based on a simple condition formulated as follows:
\[ pixel_{\text{color}} = \begin{cases} 1, & \text{if } k < n_{\text{max}} \text{ and } \operatorname{Im}(z_k) < 0, \\ 0, & \text{otherwise}. \end{cases} \]
Where \(k\) is the number of iterations performed before the radius of divergence is exceeded or \(n_{\text{max}}\) is reached.
In other words, this condition tells us that if the point has escaped before reaching the maximum number of iterations and the imaginary part of \(z\) is negative, the pixel is assigned a color \(pixel_{\text{color}} = 1\) (white). In all other cases, the pixel is assigned the color \(pixel_{\text{color}} = 0\) (black).
Color Decomposition
Color Decomposition Method
The color decomposition method is a more advanced visualization technique that enhances the results by combining the ETA algorithm with a sophisticated color interpretation. Instead of simply assigning black or white, the color of each pixel is determined by a combination of two key factors:
- Number of iterations (\(n\)) it takes for a point to exceed the divergence radius (\(r\)). This value serves as the basis for color interpolation, with more iterations resulting in a distinct color.
- Argument (\(\theta\)) of the final value \(z_n\), which defines the angle between the point and the positive real axis in the complex plane. This angle, normalized between 0 and 1, adds depth and variability to the color of the pixel.
The method works by iterating over each point in the complex plane. During each iteration, the algorithm checks if the point has exceeded the divergence radius \(r\), and if so, it records the number of iterations (\(k\)) taken for this escape to occur. The escape-time algorithm is central to this process.
The final color of each pixel is determined by interpolating three components based on the HSV (Hue, Saturation, Value) color model:
- Hue (color): The hue is determined by the normalized iteration count (\(k/n_{\text{max}}\)), which shifts the color along the spectrum based on how many iterations the point took to escape.
- Saturation: This is a fixed value of 0.8, representing the intensity of the color.
- Value (brightness): The brightness is derived from the argument \(\theta\) of the final point \(z_n\), which indicates the direction of the point in the complex plane, and is normalized to the range [0, 1].
The argument \(\theta\) is calculated as:
\[ \theta = \tan^{-1}\left(\frac{\text{Im}(z_k)}{\text{Re}(z_k)}\right), \] or \(\theta + \pi\) if \(\theta < 0\). This value is then normalized using the relation:
\[ \text{arg norm}(z_k) = \frac{\theta}{\pi}. \]
By combining the iteration count and the argument of the final point, the color decomposition method creates a smooth, continuous gradient that reveals deeper structures in the fractal visualization, providing a richer and more detailed image than simpler methods.
Field Lines
The Field Lines method is based on comparing the rates of change of the real and imaginary components of the value \( z_k \). In this case, we focus on highlighting points where the imaginary component $z_{y}$ grows significantly faster than the real component $z_{x}$.
Method checks for points where the rate of change of the imaginary component is dominant over the real component. $$|z_x| < 0{,}1 |z_{y}|,$$ where the constant \( 0.1 \) determines the threshold for the difference between the real and imaginary components. If the difference exceeds this value, the point is considered for highlighting. The condition is based on a threshold value, such that if the imaginary part of \( z_k \) is much larger than the real part, the point is emphasized. This is particularly useful for highlighting points where the trajectory's behavior shows strong growth in the imaginary direction compared to the real axis.
Level sets
The Level Sets method is based on dividing the complex plane into regions according to the number of iterations needed to determine whether a point belongs to the Mandelbrot set or not. This is a form of binary decomposition, where we examine whether the iteration count is even or odd. Each iteration naturally creates "levels," and by increasing the maximum number of iterations, we get a more precise approximation of the final set. The coloring of the points is determined by how many .
The number of iterations \( k \) is treated as a binary number. For example, the number 3 is written as 11 in binary, 4 as 100, and 5 as 101. The key observation here is that for even numbers, the last digit in the binary representation is always 0, while for odd numbers, it is 1. This property can be easily used to distinguish between even and odd numbers. If the number of iterations is odd, the point is colored black, and if it's even, the point is colored white.
Gradient Mapping
The Gradient Mapping method is a visualization technique that focuses on using a gradient to represent the number of iterations required for a point to escape to infinity. The key idea is to compute the gradient based on the iteration counts of neighboring pixels, allowing us to visualize the rate of change of the iteration count across the complex plane.
To calculate the gradient between two neighboring pixels, we subtract the iteration counts of the two pixels:
$$ \Delta \mu = \mu(k_1) - \mu(k_0) $$This difference shows how rapidly the iteration count changes between adjacent pixels and is crucial for visualizing fine details at the boundaries of the set.
The gradient is represented as a vector:
$$ \mathbf{v} = (\mu_x - \mu_0, \mu_y - \mu_0, s) $$where $\mu_x$ and $\mu_y$ are the iteration counts of neighboring pixels, $\mu_0$ is the iteration count of the current pixel, and $s$ is a scaling factor that controls the strength of the gradient.
In the code, the positions of pixels are mapped into a one-dimensional array, and the gradient is calculated for each pixel based on its neighbors. The gradient vector $\mathbf{v}$ is then normalized to produce a unit vector $\mathbf{g}$:
$$ \mathbf{g} = \frac{\mathbf{v}}{| \mathbf{v} |} $$The final color of each pixel is determined by the hue, calculated from the angle of the gradient vector in the complex plane. The angle is computed using the $\text{atan2}$ function:
$$ \text{hue} = \frac{\tan^{-1}(g_1, g_2)}{2\pi} $$The saturation is set to 0 for points inside the Mandelbrot set, and 0.5 for points outside, while the value is derived from the gradient strength.
Additionally, logarithmic correction is applied to improve the visualization of points with high iteration counts, ensuring smoother transitions at the set's boundary:
$$ \log_2(\log(|z|)) $$This correction helps to create more detailed and smooth visualizations at the edges of regions with similar iteration counts or near the set's boundary.
Histogram Coloring
The Histogram Coloring method is a technique that evenly distributes colors across the visualization area without needing to know the maximum number of iterations. The process follows several steps:
- Iteration Count Calculation: For each point on the screen, the number of iterations required for the value to exceed the divergence limit is computed. This is done using the standard escape time algorithm.
- Histogram Creation: Once the iteration counts for each point are known, a histogram is created that records how often each iteration count occurs. This histogram reflects the frequency of occurrence of different iteration counts across the visualization area.
- Cumulative Distribution Function (CDF) Calculation: After constructing the histogram, the cumulative distribution function (CDF) is computed. The CDF indicates how many pixels reached a specific iteration count within a given range. This ensures that colors are distributed according to the frequency of iteration counts, so the color mapping reflects different intensities across the area.
- CDF Normalization: The cumulative distribution function is then normalized to values in the range \([0, 1]\), allowing each pixel to be assigned an appropriate color based on its value in the CDF.
- Color Assignment: Each pixel is assigned a color based on its value in the normalized CDF. Colors are assigned using a color map, which converts CDF values into hues, while saturation and brightness remain constant. If the iteration count for a point reaches the maximum number, that point is displayed in black.
Coloring Methods for Julia set
Select one of the coloring methods for the Julia set from the dropdown menu below to explore each method in detail.
Multithreading
The Multithreading method uses principles of parallel computation, where the task is divided into smaller parts (called threads) that are processed simultaneously. JavaScript is a single-threaded language, meaning it can only execute one operation at a time (one line of code). However, multithreading can be achieved using functions like Web Workers, which allow parallel processes to run.
In this method, the main idea is to divide the displayed complex plane into several sections (chunks), with each worker processing points only from its assigned area.
Smooth Coloring
Smooth Coloring is a technique designed to overcome the visual jumps that can occur when assigning colors based on how quickly points escape the Mandelbrot set. In the standard approach, points are colored based on the number of iterations required to exceed the divergence limit, which can often lead to abrupt color transitions due to the integer nature of iteration counts. The Smooth Coloring method aims to provide smoother color transitions, resulting in a more visually fluid representation.
Instead of using the integer number of iterations, the method calculates a normalized iteration count \( \nu(z) \) for each point. This approach is based on the potential function \( \phi(z) \), which describes the growth rate of the values in the sequence and ensures smooth coloring. The formula for \( \nu(z) \) is:
$$ \nu(z) = n - \log_P\left(\frac{\log |z_n|}{\log(r)}\right), $$ where \( n \) is the number of iterations until the point \( z_n \) exceeds the divergence limit, and \( r = 2\) is the limit radius for divergence. Variable \( P \) is the exponent for \( z \rightarrow z^P + c \). This formula ensures that \( \nu(z) \) is a real number in the interval \([0, 1)\), allowing for smoother color gradients without the discontinuities of integer-based iteration counts.By utilizing this normalized value, Smooth Coloring generates more subtle transitions between colors, providing a clearer and more refined visualization.