Invariant fractal figure generation method and device, terminal equipment and storage medium

By constructing a state matrix and a double buffering mechanism, combined with spatial mapping relationships, the strict invariance and universality issues in existing fractal generation methods are solved, achieving efficient and compatible invariant fractal generation.

CN121437662BActive Publication Date: 2026-03-31WUHAN POLYTECHNIC UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511984470.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-03-31
Estimated Expiration
2045-12-26

AI Technical Summary

Technical Problem

Existing fractal generation methods, while generating high-quality and efficient fractals, cannot guarantee strict invariance and impose stringent restrictions on input conditions, thus limiting their versatility and practicality.

Method used

By constructing a state matrix to record the effective state of each pixel within the target drawing area, and employing deterministic iteration and a double-buffering mechanism, combined with spatial mapping relationships, the accuracy of each iteration and the termination condition are ensured, thereby generating an invariant fractal map.

Benefits of technology

It achieves the generation of high-quality invariant fractal maps in a finite number of steps, avoids resource waste, enhances compatibility with different types of IFS encoding, and improves generation efficiency and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121437662B_ABST
    Figure CN121437662B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a method and device for generating an invariant fractal graph, a terminal device and a storage medium, and relate to the technical field of image processing. The position of each target pixel point is determined by iterative calculation according to a first space mapping relationship between the target drawing area and the state matrix in this iteration, and a new pixel point position is obtained. Whether the new pixel point position is located in the target drawing area is determined, and the effective state of each target pixel point position in the second state matrix is updated. Whether to continue the deterministic iteration is determined according to whether the number of target pixel points after this iteration is the same as the number of target pixel points after the last iteration. If the deterministic iteration is continued, the data in the second state matrix is copied to the first state matrix, and the next deterministic iteration is performed. If the deterministic iteration is terminated, a fractal graph to be generated is generated in a drawing window, and the compatibility of different types of IFS codes is enhanced while improving the quality and execution efficiency of the fractal graph generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and more specifically, to an invariant fractal generation method, apparatus, terminal device, and storage medium. Background Technology

[0002] Fractal images are a class of graphics possessing self-similarity and complex geometric structures, widely used in computer graphics, mathematical visualization, and digital art creation. These images are generated iteratively through simple mathematical rules, capable of presenting infinitely fine details and complex forms of nature, such as mountain outlines and plant growth patterns. Therefore, they are not only used in scientific research to reveal the nature of chaotic systems and nonlinear dynamics, but also exhibit unique aesthetic value in visual arts and multimedia design. Achieving accurate generation of high-quality fractal images is of great significance for improving the realism and computational efficiency of graphics rendering.

[0003] Currently, stochastic iterative methods based on Iterated Function Systems (IFS) are a classic approach for generating fractal images. This method starts from an initial point and repeatedly maps using a set of affine transformations selected according to probability, gradually drawing a pixel set whose distribution tends to the target fractal structure. As the number of iterations increases, the generated image visually approaches the ideal result. It boasts advantages such as simple implementation and ease of programming, and is therefore widely adopted. Furthermore, in recent years, algorithms combining deep learning image reconstruction techniques and adaptive control of iterative paths have emerged, attempting to reduce redundant computation while maintaining image quality, further expanding the technological boundaries of fractal image generation.

[0004] However, the above methods still face several key problems in practical applications. While the random iterative method can generate images with good approximation, its reliance on probability sampling means it cannot guarantee complete coverage of all required pixels within a finite number of steps, nor can it avoid repetition or omission. This leads to slight differences in the results of each run, making it difficult to meet the requirement of "strict invariance"—that is, under deterministic conditions, the pixel set should not change after sufficient iterations. More importantly, this method lacks a clear termination criterion and must rely on experience to set the number of iterations; too many iterations waste resources, while too few result in incomplete images. While some improved methods attempt to introduce deterministic mechanisms to achieve pixel stabilization, they impose strict restrictions on input conditions, such as requiring all coordinate values ​​to be non-negative and the drawing area to be square. This makes many common IFS encodings unsuitable, severely limiting the algorithm's versatility and practicality. These problems collectively constitute the main bottleneck in the development of current high-precision, high-efficiency fractal image generation technology. Summary of the Invention

[0005] In view of this, the purpose of this application is to provide an invariant fractal generation method, apparatus, terminal device and storage medium, so as to improve the fractal generation quality and execution efficiency while enhancing compatibility with different types of IFS encoding.

[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows:

[0007] In a first aspect, this application provides a method for generating invariant fractal diagrams, the method comprising:

[0008] Based on the IFS encoding of the fractal image to be generated and the initial drawing area, the target drawing area corresponding to the fractal image to be generated is determined, and the state matrix corresponding to the target drawing area is generated.

[0009] The state matrix is ​​used to characterize whether each pixel in the target drawing area belongs to the valid state of the fractal image to be generated under different iterations, and the state matrix includes a first state matrix and a second state matrix with the same structure.

[0010] A deterministic iteration is performed on the pixel positions in the state matrix. For each deterministic iteration, the target pixel positions that are in a valid state after the previous iteration are obtained from the first state matrix. Based on the first spatial mapping relationship between the target drawing area and the state matrix in the current iteration, the positions of each target pixel are deterministically iterated to obtain new pixel positions.

[0011] Based on whether the new pixel position corresponding to each of the target pixel positions is located within the target drawing area, the valid state of each of the target pixel positions in the second state matrix is ​​updated, and based on whether the number of target pixel positions in the valid state after this iteration is the same as the number of target pixel positions in the valid state after the previous iteration, it is determined whether to continue the deterministic iteration of the pixel positions in the state matrix.

[0012] If the deterministic iteration of the pixel positions in the state matrix continues, the data in the second state matrix is ​​copied to the first state matrix, and the next deterministic iteration is performed.

[0013] If the deterministic iteration of the pixel positions in the state matrix is ​​terminated, the fractal image to be generated is generated in the drawing window according to the first state matrix and the second spatial mapping relationship between the target drawing area and the state matrix.

[0014] In an optional implementation, the step of determining the target drawing region corresponding to the fractal image to be generated based on the IFS parameters of the fractal image to be generated and the initial drawing region, and generating the state matrix corresponding to the target drawing region, includes:

[0015] Based on the IFS parameters of the fractal image to be generated, the minimum bounding rectangle of the fractal image to be generated is determined using a random iterative probing method.

[0016] Calculate the target scaling factor based on the minimum bounding rectangle and the initial drawing area, determine the target drawing area based on the target scaling factor and the minimum bounding rectangle, and generate the state matrix based on the target drawing area.

[0017] In an optional implementation, the step of calculating the target scaling factor based on the minimum bounding rectangle and the initial drawing area, determining the target drawing area based on the target scaling factor and the minimum bounding rectangle, and generating the state matrix based on the target drawing area includes:

[0018] The horizontal coordinate scaling factor is calculated based on the minimum and maximum horizontal coordinates of the minimum bounding rectangle and the width of the initial drawing area; the vertical coordinate scaling factor is calculated based on the minimum and maximum vertical coordinates of the minimum bounding rectangle and the height of the initial drawing area.

[0019] The minimum value of the horizontal axis scaling factor and the vertical axis scaling factor is determined as the target scaling factor;

[0020] The width of the target drawing area is calculated based on the minimum and maximum values ​​of the horizontal coordinate and the target scaling factor, and the height of the target drawing area is calculated based on the minimum and maximum values ​​of the vertical coordinate and the target scaling factor, so as to determine the target drawing area.

[0021] The state matrix is ​​generated based on the width and height of the target drawing area, and the position of each pixel in the state matrix is ​​initialized with a valid state.

[0022] In an optional implementation, the step of obtaining the target pixel positions that are in a valid state after the previous iteration from the first state matrix, and performing deterministic iteration on each target pixel position according to the first spatial mapping relationship between the target drawing area and the state matrix in the current iteration to obtain new pixel positions includes:

[0023] The position of the pixel in the first state matrix that has the same number as the previous iteration is determined as the target pixel position;

[0024] For each target pixel location, determine the pixel coordinates of the target pixel location in the target drawing area, and determine the new pixel location based on the pixel coordinates and the first spatial mapping relationship in this iteration.

[0025] In an optional implementation, the first spatial mapping relationship is represented by the following formula:

[0026]

[0027] in, , , , ;

[0028] i and j represent the pixel positions in the state matrix. , , , , , Let be the iteration parameters for this iteration, and k represent the k-th iteration function. , The minimum x-coordinate of the smallest enclosing rectangle. y represents the pixel coordinates of the pixel position in the state matrix within the target drawing area. The minimum value of the ordinate representing the smallest bounding rectangle. Characterizing the scaling factor of the horizontal axis, Characterized by the scaling factor on the ordinate. Characterizing the target scaling factor, Characterizing the horizontal axis offset, Characterizing the offset of the vertical axis, Characterizes the width of the target drawing area. Characterizes the height of the target drawing area. The maximum x-coordinate of the smallest enclosing rectangle. The maximum value of the ordinate of the smallest enclosing rectangle.

[0029] In an optional implementation, the step of updating the valid state of each target pixel position in the second state matrix based on whether the new pixel position corresponding to each target pixel position is located within the target drawing area, and determining whether to continue deterministic iteration of the pixel positions in the state matrix based on whether the number of target pixel positions in the valid state after the current iteration is the same as the number of target pixel positions in the valid state after the previous iteration, includes:

[0030] For each target pixel location, if the new pixel location corresponding to the target pixel location is located within the target drawing area, then the value at the target pixel location in the second state matrix is ​​updated to the value of the current iteration number to indicate that the target pixel location is still in a valid state after the current iteration.

[0031] If the new pixel position corresponding to the target pixel position is not located within the target drawing area, the value at the pixel position in the second state matrix will not be updated to indicate that the pixel position is invalid after this iteration.

[0032] If the number of target pixel positions in the valid state after this iteration is different from the number of target pixel positions in the valid state after the previous iteration, then the deterministic iteration of the pixel positions in the state matrix continues.

[0033] If the number of pixel positions in a valid state after this iteration is the same as the number of pixel positions in a valid state after the previous iteration, then the deterministic iteration of the pixel positions in the state matrix is ​​terminated.

[0034] In an optional implementation, generating the fractal image to be generated in the drawing window based on the first state matrix and the second spatial mapping relationship between the target drawing region and the state matrix includes:

[0035] The second spatial mapping relationship is used to determine the pixel coordinates of each target pixel in the first state matrix in the drawing window, and the pixel coordinates are used to draw points in the drawing window to obtain the generated fractal image.

[0036] The second spatial mapping relationship is represented by the following formula:

[0037]

[0038] Where i and j represent the pixel positions in the state matrix, and x and y represent the pixel coordinates of the pixel positions in the target drawing area. Characterizes the width of the drawing window. Characterizes the height of the drawing window. Characterizes the width of the target drawing area. Characterizes the height of the target drawing area.

[0039] Secondly, this application provides an invariant fractal diagram generation apparatus, the apparatus comprising:

[0040] The generation module is used to determine the target drawing region corresponding to the fractal image to be generated based on the IFS encoding and the initial drawing region of the fractal image to be generated, and to generate the state matrix corresponding to the target drawing region.

[0041] The state matrix is ​​used to characterize whether each pixel in the target drawing area belongs to the valid state of the fractal image to be generated under different iterations, and the state matrix includes a first state matrix and a second state matrix with the same structure.

[0042] The iteration module is used to perform deterministic iteration on the pixel positions in the state matrix. For each deterministic iteration, the target pixel positions that are in a valid state after the previous iteration are obtained from the first state matrix. Based on the first spatial mapping relationship between the target drawing area and the state matrix in the current iteration, the positions of each target pixel are deterministically iterated to obtain new pixel positions.

[0043] The iteration module is further configured to update the valid state of each target pixel position in the second state matrix according to whether the new pixel position corresponding to each target pixel position is located within the target drawing area, and determine whether to continue to perform deterministic iteration on the pixel positions in the state matrix according to whether the number of target pixel positions in the valid state after this iteration is the same as the number of target pixel positions in the valid state after the previous iteration.

[0044] The iteration module is further configured to, if the deterministic iteration of the pixel positions in the state matrix continues, copy the data in the second state matrix to the first state matrix and continue to execute the next deterministic iteration;

[0045] The iteration module is further configured to, if the deterministic iteration of the pixel positions in the state matrix is ​​terminated, generate the fractal image to be generated in the drawing window according to the first state matrix and the second spatial mapping relationship between the target drawing area and the state matrix.

[0046] Thirdly, this application provides a terminal device including a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor is used to execute the computer program to implement the method described in any of the foregoing embodiments.

[0047] Fourthly, this application provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in any of the foregoing embodiments.

[0048] The invariant fractal generation method, apparatus, terminal device, and storage medium provided in this application determine the target drawing region corresponding to the fractal based on the IFS encoding and initial drawing region of the fractal to be generated, and generate a matching state matrix. This state matrix records whether each pixel within the target drawing region is a valid component of the fractal to be generated at different iteration counts, thus providing structured data support for subsequent iterations. In each deterministic iteration, the positions of target pixels that were in a valid state after the previous iteration are extracted from the first state matrix. Combined with the first spatial mapping relationship between the target drawing region and the state matrix in the current iteration, coordinate transformations are performed on these target pixel positions to obtain corresponding new pixel positions. Therefore, it can be ensured that each valid pixel migrates according to a preset geometric transformation logic. Based on this, for each new pixel position obtained through deterministic iteration, it is determined whether it is still within the target drawing area. This updates the valid state of the corresponding target pixel position in the second state matrix. Simultaneously, the number of target pixel positions in a valid state after this iteration is counted and compared with the number after the previous iteration. This comparison serves as the basis for determining whether to continue iteration, thus deciding whether to terminate the deterministic iteration process. If continued iteration is needed, the data from the second state matrix is ​​copied to the first state matrix, achieving phased synchronization of state information. This allows the next iteration to proceed based on the latest valid pixel distribution. This alternating use of two matrices ensures data continuity and logical correctness during the iteration process. When it is determined that iteration should no longer continue, the final valid state information retained in the first state matrix, combined with the second spatial mapping relationship between the target drawing area and the state matrix, is used to convert the qualifying pixel positions into actual coordinates in the drawing window and complete the graphic output. In this way, through explicit management of the valid states of pixels in the state matrix, each iteration accurately tracks the changing trend of the valid pixel set and adaptively determines the iteration termination time by comparing the consistency of the number of valid pixels in adjacent iterations in real time. This state-convergence-based judgment mechanism effectively avoids the problems of incomplete images due to insufficient iteration or resource waste due to excessive iteration, thus ensuring that the generated results meet the requirement of strict invariance. Furthermore, the entire process does not depend on specific initial conditions or encoding forms; it only requires any valid IFS encoding to drive the complete generation process, making it applicable to various fractal structure construction scenarios. Therefore, this scheme improves the quality and execution efficiency of fractal image generation while enhancing compatibility with different types of IFS encodings, demonstrating good versatility.

[0049] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0050] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 A block diagram of a terminal device provided in an embodiment of this application is shown;

[0052] Figure 2 This paper illustrates a flowchart of an invariant fractal generation method provided in an embodiment of this application.

[0053] Figure 3 A schematic diagram of the target rectangular area corresponding to the first test case is shown;

[0054] Figure 4 A schematic diagram of the invariant fractal corresponding to the first test case is shown;

[0055] Figure 5 A schematic diagram of the target rectangular area corresponding to the second test case is shown;

[0056] Figure 6 A schematic diagram of the invariant fractal corresponding to the second test case is shown;

[0057] Figure 7 A schematic diagram of the target rectangular area corresponding to the third test case is shown;

[0058] Figure 8 A schematic diagram of the invariant fractal corresponding to the third test case is shown;

[0059] Figure 9 This paper illustrates a functional block diagram of an invariant fractal generation apparatus provided in an embodiment of this application. Detailed Implementation

[0060] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can be arranged and designed in various different configurations.

[0061] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0062] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0063] Figure 1 Please refer to the block diagram of a terminal device provided in the embodiments of this application. Figure 1 The terminal device includes a memory, a processor, and a communication module. These components are electrically connected directly or indirectly to enable data transmission or interaction. For example, they can be electrically connected via one or more communication buses or signal lines.

[0064] Memory is used to store computer programs or data that can be executed by a processor. Memory can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc.

[0065] The processor is used to read / write data or computer programs stored in memory and execute the computer program to implement an invariant fractal generation method.

[0066] The communication module is used to establish communication connections between the terminal device and other communication terminals via the network, and to send and receive data via the network.

[0067] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the terminal device; the terminal device may also include components that are larger than those shown. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0068] The following is based on the above. Figure 1 The terminal device in this application is the execution subject. The invariant fractal graph generation method provided in this embodiment is described executively with reference to the flowchart. Specifically, Figure 2 For a flowchart illustrating the invariant fractal graph generation method provided in this application embodiment, please refer to [link / reference]. Figure 2 The method includes:

[0069] Step S20: Based on the IFS encoding of the fractal image to be generated and the initial drawing area, determine the target drawing area corresponding to the fractal image to be generated, and generate the state matrix corresponding to the target drawing area.

[0070] The state matrix is ​​used to characterize whether each pixel in the target drawing area belongs to a valid state of the fractal image to be generated under different iterations, and the state matrix includes a first state matrix and a second state matrix with the same structure.

[0071] It should be understood that during the fractal image generation process, to ensure the geometric invariance and visual integrity of the drawn graphic, a target drawing area adapted to the current fractal structure must be precisely determined based on the user-input IFS code and the user-defined initial drawing area. This target drawing area must not only accommodate all valid pixels of the fractal graphic determined by the IFS code, but also achieve efficient drawing under limited computing resources.

[0072] Based on this, in order to support state tracking and data updates in the subsequent deterministic iteration process, it is necessary to construct a data structure that can characterize whether each pixel in the target drawing area still belongs to the effective components of the fractal map under different iterations, namely the state matrix.

[0073] The state matrix is ​​matched with the target drawing area. In one possible implementation, the state matrix is ​​organized as a two-dimensional array, with the number of rows and columns corresponding to the width and height of the target drawing area, respectively. Each element is used to store information about whether the corresponding pixel is still in a valid state in a certain iteration.

[0074] It is worth noting that the state matrix contains two identical first and second state matrices, which together form a double-buffering mechanism: one is used to store the valid pixel states before the current iteration, and the other is used to accumulate the update results after the current iteration. This design avoids data drift caused by state overwriting during each iteration, ensuring the correctness of the iterative logic.

[0075] It's important to note that the state matrix here can exist in memory as an array or matrix object to improve access efficiency and processing speed. Alternatively, depending on the specific application scenario, especially when the target drawing area is large and may lead to excessive memory consumption, external storage methods can be used, such as persistent storage via binary files. In this case, the row and column specifications of each binary file strictly correspond to the width and height of the target drawing area. By mapping the state matrix to binary files, the dependence on contiguous memory space can be significantly reduced at the expense of some access performance, thereby supporting the generation of large-scale invariant fractals.

[0076] Furthermore, the larger the size of the fractal image to be generated, the larger the corresponding target drawing area will be, and the larger the required binary file will be. Therefore, generating large invariant fractal images will consume more computation time.

[0077] Understandably, this embodiment can employ an architecture combining the target drawing area and a dual-state matrix. On the one hand, geometric analysis ensures the integrity and proportional consistency of the graphic presentation; on the other hand, a structured state recording mechanism provides a reliable data foundation for subsequent deterministic iterations. By introducing a dual-buffered structure for the state matrix and a flexible storage strategy, the aim is to achieve a generalized, high-precision, and resource-controllable generation capability for invariant fractal maps under arbitrary IFS encoding.

[0078] Step S21: Perform deterministic iteration on the pixel positions in the state matrix. For each deterministic iteration, obtain the target pixel positions that are in a valid state after the previous iteration from the first state matrix. Based on the first spatial mapping relationship between the target drawing area and the state matrix in this iteration, perform deterministic iteration on each target pixel position to obtain new pixel positions.

[0079] In this embodiment, the deterministic iterative process aims to generate an invariant fractal image that maintains a stable number of pixels in a systematic and reproducible manner. During this process, the state matrix, as a data structure recording whether each pixel within the target drawing area belongs to a valid component of the fractal image at different iteration numbers, undertakes the crucial functions of information storage and updating.

[0080] The first state matrix stores the valid state of each pixel after the previous deterministic iteration, while the second state matrix receives the calculation result of the current iteration. During the execution of these steps, each deterministic iteration is based on the result of the previous iteration.

[0081] In practice, it is necessary to obtain the positions of all target pixels that were in a valid state after the previous iteration from the first state matrix. This means identifying the coordinates of all pixels that were still determined to constitute the fractal map in the previous iteration. These target pixel positions represent the initial dataset that needs to participate in this round of transformation.

[0082] Based on this, according to the first spatial mapping relationship between the target drawing region and the state matrix in this iteration, deterministic iterative operations are performed on the positions of each target pixel. This first spatial mapping relationship reflects the correlation between the discrete index positions in the state matrix and the actual coordinates within the target drawing region, and is combined with the parameters of the iterative function system to perform geometric transformations, thereby obtaining new pixel positions. This process essentially applies a set of affine transformation rules to each valid target pixel, simulating its evolution path under the fractal generation mechanism.

[0083] Step S22: Update the valid state of each target pixel position in the second state matrix according to whether the new pixel position corresponding to each target pixel position is located within the target drawing area. Then, determine whether to continue the deterministic iteration of the pixel positions in the state matrix based on whether the number of target pixel positions in the valid state after this iteration is the same as the number of target pixel positions in the valid state after the previous iteration.

[0084] Step S23: If the deterministic iteration of the pixel positions in the state matrix continues, then the data in the second state matrix is ​​copied to the first state matrix, and the next deterministic iteration is performed.

[0085] Step S24: If the deterministic iteration of the pixel positions in the state matrix is ​​terminated, then the fractal image to be generated is generated in the drawing window according to the first state matrix and the second spatial mapping relationship between the target drawing area and the state matrix.

[0086] Optionally, during the deterministic iteration of the invariant fractal, the stability of the generated image on the pixel set needs to be ensured through continuous state updates and convergence judgments.

[0087] During the above steps, the terminal device can first determine whether the newly obtained pixel position is within the target drawing area. If the new pixel position is still within the target drawing area, it is considered that the target pixel position remains valid after this iteration, and the number of target pixel positions in a valid state after this iteration is simultaneously accumulated. Conversely, if the new pixel position is not within the target drawing area, it means that the target pixel no longer belongs to the fractal image to be generated after this iteration and no longer remains valid.

[0088] It should be noted that since the pixel position refers to the position in the state matrix, the essence here is to determine whether the new pixel position is located in the state matrix, thereby indirectly determining whether it is located within the target drawing area.

[0089] Based on this, the terminal device can determine whether the fractal structure has reached a stable state by comparing the number of target pixel positions that are in a valid state after the current iteration with that after the previous iteration.

[0090] Specifically, when the two are not equal, it indicates that the pixel set is still evolving and has not yet entered a constant state, therefore, the next round of deterministic iteration needs to be executed. To achieve the transfer of iteration states, the terminal device can copy the data in the second state matrix to the first state matrix, so that the latter carries the latest effective pixel distribution information, and reset the relevant counting variables before returning to the next iteration process. This mechanism ensures that each iteration is based on the final result of the previous one, thereby maintaining the continuity and logical consistency of the entire evolution process.

[0091] Conversely, when the number of target pixel positions in a valid state after the current iteration is equal to the number after the previous iteration, it indicates that the pixel set has not shrunk or expanded after the current affine transformation, meaning that geometric convergence has been achieved. At this point, further deterministic iterations of the pixel positions in the state matrix can be terminated, marking the completion of the core computational stage of the generation process.

[0092] Subsequently, based on the final valid states recorded in the first state matrix, and combined with the second spatial mapping relationship between the target drawing area and the state matrix, a fractal image to be generated will be produced in the drawing window. This second spatial mapping relationship is used to convert the discrete index positions in the state matrix into actual display coordinates within the drawing window, ensuring that the image can be presented according to the correct spatial layout.

[0093] The key to this embodiment lies in the introduction of a dynamic state update and quantity comparison mechanism, which enables precise determination of the convergence behavior of the fractal graph, avoiding the waste of computational resources caused by excessive iteration, while ensuring that the generated result meets the strict invariance requirement within a finite number of steps. Therefore, this step not only completes the transition from iterative calculation to graphical output but also constitutes the technical closed loop for the entire method to achieve efficient and reliable generation of invariant fractal graphs.

[0094] It should be noted that determining whether the graph has reached a stable state is crucial in deciding whether the iteration terminates during the generation of the invariant fractal image. In this embodiment, each iteration applies an iterative function system to transform all currently valid pixels and maps them to new positions. If the new position still falls within a preset rectangular area, the point is retained as a valid pixel for the next round; otherwise, it is excluded.

[0095] As the number of iterations increases, some pixels will gradually disappear because they are mapped beyond the boundary or fall into already covered positions, resulting in a monotonically decreasing trend in the total number of effective pixels. That is, ,in, , The number of target pixels in a valid state after the i-th deterministic iteration. This represents the number of target pixels that are in a valid state after the (i+1)th deterministic iteration.

[0096] When, after a certain iteration, the number of valid pixels is exactly the same as in the previous round, it means that all retainable points have entered the cyclic mapping state, and subsequent iterations will not cause any further changes to the set. In other words, if... If the invariant fractal graph can be drawn in just k iterations, then the graph structure has converged and the pixel distribution tends to be constant. Therefore, we can determine whether the fractal graph has reached an invariant state by comparing whether the number of pixels is the same after two adjacent iterations. In other words, if ,but .

[0097] The number of iterations, k, at which the number of pixels in the two preceding and following iterations is equal for the first time is called the minimum number of iterations. It marks the minimum number of computational steps required to generate the target fractal image. Before this number, the image is still evolving, and the pixel set is not yet stable; once this number is reached, further iterations will no longer change the result. This value not only represents the critical point of algorithm convergence but also corresponds to the shortest time required to draw the invariant fractal image. Using this minimum number of iterations ensures that the final image meets the requirement of strict invariance while avoiding unnecessary redundant computations, thus achieving a balance between efficiency and accuracy.

[0098] In other words, when the number of iterations exceeds k, the number of effective target pixels remains stable and no longer changes. When the number of iterations is less than k, the number of effective target pixels can still be further reduced through deterministic iterations. When the number of iterations reaches k, it ensures the generation of an accurate invariant fractal map while minimizing computational cost. Based on this, we can determine whether the minimum number of iterations has been reached by comparing the number of effective target pixel positions after the current iteration with the number after the previous iteration. If the minimum number of iterations has been reached, it can be determined that no further deterministic iteration is needed.

[0099] Furthermore, it should be understood that the first spatial mapping relationship is used to transform the actual coordinates within the target drawing area into pixel positions in the state matrix, and then perform deterministic iterative calculations to obtain new pixel positions. In contrast, the second spatial mapping relationship serves to transform the final stable state into the visualization output space; that is, after the iteration terminates, it restores the pixel positions that are still in a valid state in the first state matrix to the display coordinates in the drawing window.

[0100] In other words, this embodiment achieves bidirectional precise positioning between the data space of the state matrix and the display space of the target drawing area by defining a first spatial mapping relationship and a second spatial mapping relationship respectively: the former serves the iterative calculations within the algorithm, ensuring that each transformation is based on correct geometric semantics; the latter is geared towards result presentation, ensuring that the generated fractal image can be correctly rendered on the specified output device. Thus, these two types of spatial mapping relationships together construct a complete transformation channel from the abstract matrix state to the visible graphic, satisfying both the requirement for accurate coordinate transfer during deterministic iteration and supporting the precise layout of the final image in the user interface.

[0101] The invariant fractal generation method provided in this application determines the target drawing region corresponding to the fractal based on the IFS encoding of the fractal to be generated and the initial drawing region, and generates a matching state matrix. This state matrix records whether each pixel within the target drawing region is a valid component of the fractal to be generated at different iteration counts, thus providing structured data support for subsequent iterations. In each deterministic iteration, the positions of target pixels that were in a valid state after the previous iteration are extracted from the first state matrix. Combined with the first spatial mapping relationship between the target drawing region and the state matrix in the current iteration, coordinate transformation is performed on these target pixel positions to obtain corresponding new pixel positions. This ensures that each valid pixel migrates according to a preset geometric transformation logic. Based on this, for each new pixel position obtained through deterministic iteration, it is determined whether it is still within the target drawing region, thereby updating the valid state of the corresponding target pixel position in the second state matrix. Simultaneously, the number of target pixel positions in a valid state after the current iteration is counted and compared with the number of target pixel positions after the previous iteration, serving as the basis for determining whether to continue iteration and whether to terminate the deterministic iteration process. When further iterations are needed, the data from the second state matrix is ​​copied entirely to the first state matrix, achieving phased synchronization of state information. This allows the next iteration to proceed based on the latest effective pixel distribution. This design, using two matrices alternately, ensures data continuity and logical correctness during the iteration process. When it is determined that iterations should cease, the final effective state information retained in the first state matrix, combined with the second spatial mapping relationship between the target drawing area and the state matrix, is used to convert the positions of eligible pixels into actual coordinates in the drawing window and complete the graphic drawing output. Thus, through explicit management of the effective states of pixels in the state matrix, each iteration accurately tracks the changing trend of the effective pixel set and adaptively determines the iteration termination time by comparing the consistency of the number of effective pixels in adjacent iterations in real time. This state convergence-based judgment mechanism effectively avoids the problems of incomplete images due to insufficient iterations or resource waste due to excessive iterations, thereby ensuring that the generated results meet the requirement of strict invariance. Furthermore, the entire process does not depend on specific initial conditions or encoding forms; only any valid IFS encoding needs to be input to drive the complete generation process, making it suitable for various fractal structure construction scenarios. Therefore, this scheme improves the quality of fractal graph generation and execution efficiency, while also enhancing compatibility with different types of IFS encoding, demonstrating good versatility.

[0102] Understandably, in order to achieve efficient generation of invariant fractals based on the deterministic iterative method of rectangular regions, it is necessary to focus on solving three key issues at the algorithm design level: geometric consistency, coordinate mapping accuracy, and data storage efficiency.

[0103] First, in terms of geometric representation, the size and scaling parameters of the drawing area need to be dynamically adjusted according to the actual distribution range of the fractal structure to obtain the target drawing area, ensuring that the generated image fully adapts to the output space while maintaining the original shape characteristics. Second, a first spatial mapping relationship and a second spatial mapping relationship need to be established to achieve bidirectional and accurate positioning between the data space of the state matrix and the display space of the target drawing area. Third, in terms of data management, a state matrix needs to be used as the core storage carrier to record the effective state of each pixel before and after each iteration, such as two independent binary files, so as to achieve efficient iterative updates of data.

[0104] The following provides a possible implementation method for determining the target drawing region corresponding to the fractal image to be generated based on the IFS parameters of the fractal image to be generated and the initial drawing region, and generating the state matrix corresponding to the target drawing region.

[0105] Specifically, the terminal device can determine the minimum bounding rectangle of the fractal image to be generated based on the IFS parameters of the fractal image to be generated using the random iterative probing method, calculate the target scaling factor based on the minimum bounding rectangle and the initial drawing area, determine the target drawing area based on the target scaling factor and the minimum bounding rectangle, and generate a state matrix based on the target drawing area.

[0106] Optionally, if the width and height of the initial drawing area are W and H respectively, then the initial drawing area D can be characterized as: It should be understood that the drawing area should be smaller than the drawing window to ensure that the drawn graphics can be fully displayed in the drawing window.

[0107] In the process of generating invariant fractal images, the proper determination of the target drawing region is a prerequisite for ensuring the geometric consistency and display integrity of the image. To achieve this goal, it is first necessary to obtain the actual spatial distribution range of the fractal image to be generated, that is, its minimum bounding rectangle.

[0108] This process, based on the IFS parameters of the fractal image to be generated, uses a random iterative probing method to perform preliminary evolution calculations on the pixels of the fractal structure. Through random iteration, the terminal device can quickly converge to the approximate outline of the fractal image and record the maximum, minimum, maximum, and minimum values ​​of the horizontal and vertical coordinates of all generated points. These extreme values ​​collectively define the smallest axis-aligned rectangular region that can completely cover the fractal image, i.e., the smallest enclosing rectangle.

[0109] During the above steps, the random iterative probing method is not used for the final image rendering, but rather as an efficient preprocessing technique to explore the spatial extension characteristics of the fractal structure. Since the attractors corresponding to different IFS codes have varying geometric shapes and coordinate distributions, directly using a fixed drawing area may lead to image cropping or scaling distortion. Therefore, the minimum bounding rectangle obtained through this probing mechanism provides basic boundary information for the subsequent adaptive adjustment of the target drawing area.

[0110] Next, the boundary information of the minimum bounding rectangle is used to perform co-calculation with the initial drawing area. The actual width and height are recalculated using the target scaling factor to determine the target drawing area, so that it can fully accommodate the scaled fractal structure without exceeding the initially set display boundary.

[0111] The core concept of this embodiment lies in using the minimum bounding rectangle obtained through random iterative probing as a geometric reference, combined with a constraint mechanism of the target scaling factor, to achieve an adaptive mapping from the mathematical model to the visualization space. The target drawing area determined in this way not only satisfies the requirements of graphic integrity but also ensures display consistency under different resolutions or window sizes. Subsequently, a first state matrix and a second state matrix with identical structures are generated based on this target drawing area, serving as data carriers for recording the iterative states of pixels.

[0112] This step completes the transformation from IFS parameters to an operable drawing space, laying a dual foundation of data and geometry for subsequent deterministic iteration, state updates, and coordinate mapping, thus enabling the entire generation process to have good versatility and stability.

[0113] In one possible implementation, the terminal device can calculate the scaling factor in both directions based on the span of the minimum enclosing rectangle in the horizontal and vertical directions, and the width and height of the initial drawing area, and then select the smaller of the two as the unified target scaling factor. This selection strategy aims to ensure that the aspect ratio is maintained when the fractal image is adapted to the drawing area, avoiding image stretching or compression distortion.

[0114] Specifically, the terminal device can calculate the horizontal coordinate scaling factor based on the minimum and maximum horizontal coordinates of the minimum bounding rectangle and the width of the initial drawing area, and calculate the vertical coordinate scaling factor based on the minimum and maximum vertical coordinates of the minimum bounding rectangle and the height of the initial drawing area; determine the minimum of the horizontal and vertical coordinate scaling factors as the target scaling factor; calculate the width of the target drawing area based on the minimum and maximum horizontal coordinates and the target scaling factor, and calculate the height of the target drawing area based on the minimum and maximum vertical coordinates and the target scaling factor to determine the target drawing area; generate a state matrix based on the width and height of the target drawing area, and perform effective state initialization on the position of each pixel in the state matrix.

[0115] It should be understood that in determining the target drawing area, both the geometric integrity of the fractal image and its adaptability to the display space must be considered. To achieve this goal, firstly, based on the difference between the maximum and minimum x-coordinates of the minimum bounding rectangle, and combined with the width of the initial drawing area, a scaling reference is calculated to horizontally stretch or compress the original fractal structure into the initial drawing space; this is the x-coordinate scaling factor. Similarly, based on the relationship between the extreme values ​​of the minimum bounding rectangle's x-coordinates and the height of the initial drawing area, the y-coordinate scaling factor is derived. These two scaling factors respectively reflect the degree of scale adjustment required in the horizontal and vertical directions to completely embed the fractal structure into the initial drawing area without altering the graphic details.

[0116] Specifically, the terminal device can calculate the scaling factor of the horizontal axis using the following formula. and the scaling factor of the vertical axis :

[0117]

[0118]

[0119] Where W represents the width of the initial drawing area, and H represents the height of the initial drawing area. Represents the maximum value of the x-axis. Represents the minimum value of the x-axis. Represents the maximum value of the ordinate. It represents the minimum value of the vertical axis.

[0120] If each independent scaling factor is used directly during the above steps, the image may be overstretched or compressed in a certain direction, destroying its original aspect ratio and causing visual distortion. To avoid this type of distortion, the terminal device can select the smaller value between the horizontal and vertical scaling factors as the unified target scaling factor. .Right now This strategy ensures that, in subsequent mappings, the fractal structure will not exceed the boundary of the target drawing area, whether in the width or height direction, while preserving its original shape characteristics.

[0121] Based on this, the target scaling factor is applied again to the actual span of the minimum enclosing rectangle: the final target drawing area width is determined by multiplying the difference between the maximum and minimum x-coordinate values ​​by the target scaling factor, rounding down, and adding one; similarly, the same operation is performed on the y-coordinate range to obtain the height of the target drawing area. The resulting target drawing area can fully accommodate the scaled fractal image while strictly meeting the requirement of display without distortion.

[0122] Specifically, the terminal device can calculate the width of the target drawing area using the following formula. and height :

[0123]

[0124]

[0125] in, Represents the maximum value of the x-axis. Represents the minimum value of the x-axis. Represents the maximum value of the ordinate. Representing the minimum value of the ordinate, Characterizes the target scaling factor.

[0126] The core concept of this embodiment lies in achieving a precise conversion from the detected spatial distribution to the operable drawing size by introducing a target scaling factor as a coordination mechanism, while maintaining the geometric consistency of the fractal image. Once the width and height of the target drawing area are determined, a data structure—the state matrix—can be constructed to record the evolution of pixel states.

[0127] Specifically, two identical state matrices are generated, with the number of rows corresponding to the height of the target drawing area. The number of columns corresponds to its width. Each element identifies whether the corresponding position is a valid pixel after a specific number of iterations. During initialization, the state values ​​of all positions can be set to zero or other default flags to provide a starting point for the subsequent deterministic iteration process.

[0128] In one example, the state matrix can be in binary file format. The terminal device can create a first binary file s.txt and a second binary file t.txt, and open them in write-only mode, with each file having a specific size. OK The column initializes the value of all elements to 0 after creation.

[0129] At this point, the deterministic iteration operation has not yet begun; some iteration parameters need further configuration. Specifically, the number of deterministic iterations, m, can be set to 1 to indicate that the first deterministic iteration is about to begin, and the number of target pixel positions that are in a valid state before the iteration can be set. Set as This indicates that all pixel positions in both binary files are currently in a valid state. Furthermore, since the first iteration has not yet begun, the number of target pixel positions in a valid state after the iteration also needs to be counted. Set to 0.

[0130] During iteration, the terminal device can determine the position of the pixel in the first state matrix that has the same number as the previous iteration as the target pixel position; for each target pixel position, determine the pixel coordinates of the target pixel position in the target drawing area, and determine the new pixel position based on the pixel coordinates and the first spatial mapping relationship under this iteration.

[0131] It should be understood that during deterministic iteration, it is necessary to accurately identify the pixel positions that still belong to the valid structure of the fractal graph after the previous iteration in order to perform the next transformation operation on them. To this end, one possible implementation can use a numerical labeling mechanism in the state matrix to distinguish valid states at different iteration numbers.

[0132] Specifically, the first state matrix records the pixel distribution after the previous iteration. Each element stores an integer value corresponding to the number of iterations required for that position to become a valid pixel. When entering a new iteration, the terminal device can traverse all positions in the first state matrix and compare the stored value with the result of the current iteration number minus one (i.e., the previous iteration number). If the two are equal, it means that the position was identified as a valid pixel in the previous iteration, and therefore should be included in the processing set of this iteration, i.e., determined as the target pixel position.

[0133] During the above steps, the position of each identified target pixel is still in the discrete index space of the state matrix and cannot directly participate in geometric transformation operations. Therefore, it is necessary to first restore its actual coordinates in the target drawing area.

[0134] In one possible implementation, the terminal device can determine the pixel coordinates of the target pixel in the target drawing area through the second spatial mapping relationship, and then determine the new pixel position based on the pixel coordinates and the first spatial mapping relationship.

[0135] The core concept of this embodiment is that by binding the numerical identifiers in the state matrix with the number of iterations, dynamic tracking of the effective pixel set is achieved, and the accurate mapping from the data structure to the geometric space is completed with the help of spatial mapping relationship, so that each deterministic iteration can perform transformation calculations based on the correct physical coordinates.

[0136] Alternatively, the first spatial mapping relationship can be represented by the following formula:

[0137]

[0138] in, , , , .

[0139] i and j represent the pixel positions in the state matrix. , , , , , Let be the iteration parameters for this iteration, and k represent the k-th iteration function. , The minimum x-coordinate of the smallest enclosing rectangle. y represents the pixel coordinates of the pixel position in the state matrix within the target drawing area. The minimum value of the ordinate representing the smallest bounding rectangle. Characterizing the scaling factor of the horizontal axis, Characterized by the scaling factor on the ordinate. Characterizing the target scaling factor, Characterizing the horizontal axis offset, Characterizing the offset of the vertical axis, Characterizes the width of the target drawing area. Characterizes the height of the target drawing area. The maximum x-coordinate of the smallest enclosing rectangle. The maximum value of the ordinate of the smallest enclosing rectangle.

[0140] It should be noted that each deterministic iteration includes a systematic and comprehensive evolutionary calculation of the current set of valid pixels. Specifically, in a single deterministic iteration, for all target pixel positions in the first state matrix that are in a valid state after the previous iteration, the algorithm does not apply only a single transformation function, but executes all n transformation functions defined by IFS encoding. For each valid pixel, it is substituted into the k=1 to k=n iteration functions for coordinate mapping calculation, thereby obtaining n corresponding new pixel positions.

[0141] This process is essentially an exhaustive search for all possible evolution paths of the pixel in the current iteration step: as long as at least one of the transformation results is still within the target drawing area, it is determined that the position of the target pixel is still valid after this iteration.

[0142] By performing the n transformation calculations on each valid pixel in each iteration, the algorithm achieves deterministic simulation of the dynamic behavior of the entire IFS system, ensuring the integrity and reproducibility of the fractal structure evolution process. This avoids pixel omissions or distribution fluctuations caused by insufficient sampling in traditional stochastic iterative methods, thus providing computational assurance for the final generation of strictly invariant and geometrically accurate fractal images.

[0143] It should be understood that during deterministic iteration, a precise and reversible mapping relationship needs to be established between the geometric coordinates within the target drawing area and the discrete storage locations in the state matrix to ensure that the result of each affine transformation is correctly mapped into the data structure. The first spatial mapping relationship performs this function, mapping the iteratively processed physical coordinates to row and column indices in the state matrix, thereby supporting subsequent state update operations. This mapping process is not a simple linear scaling, but a composite transformation mechanism that integrates the spatial distribution of the original fractal structure, the size constraints of the target drawing area, a unified scaling factor, and a centering offset.

[0144] In this embodiment, , , , , , These iteration parameters are different in each iteration, and the number of iteration parameters and the number n of iteration functions can be determined through IFS encoding. The first spatial mapping relationship can be based on the transformation coefficients corresponding to the current iteration. , , , , , The target scaling factor calculated in advance Horizontal axis offset offset from the vertical axis Horizontal axis scaling factor and the scaling factor of the vertical axis The physical meaning of the horizontal and vertical coordinate offsets in the construction is to compensate for the blank areas caused by proportional scaling, so that the center of the transformed image is aligned with the center of the drawing area.

[0145] Optionally, after determining the new pixel position corresponding to each target pixel position, the terminal device may, for each target pixel position, determine whether the new pixel position corresponding to that target pixel position is still within the target drawing area.

[0146] If the new pixel position corresponding to the target pixel position is located within the target drawing area, the value at the target pixel position in the second state matrix is ​​updated to the value of the current iteration number to indicate that the target pixel position is still in a valid state after this iteration; if the new pixel position corresponding to the target pixel position is not located within the target drawing area, the value at the pixel position in the second state matrix is ​​not updated to indicate that the pixel position is in an invalid state after this iteration.

[0147] Next, the number of target pixel positions in a valid state after this iteration is counted. If the number of target pixel positions in a valid state after this iteration is different from the number of target pixel positions in a valid state after the previous iteration, then the deterministic iteration of the pixel positions in the state matrix continues; if the number of pixel positions in a valid state after this iteration is the same as the number of pixel positions in a valid state after the previous iteration, then the deterministic iteration of the pixel positions in the state matrix is ​​terminated.

[0148] It should be understood that during the deterministic iteration process, the validity of the pixel position after each transformation needs to be judged to determine whether it should continue to be retained in the structure of the fractal image.

[0149] Specifically, after a target pixel undergoes coordinate transformation through the first spatial mapping relationship, the resulting new pixel position must be verified to see if it falls within the preset target drawing area. If the row and column indices of the new position satisfy the boundary conditions of the target drawing area, it is considered to be within the valid range, indicating that the point still belongs to the fractal image after this iteration.

[0150] At this point, the terminal device can update the value at the corresponding position in the second state matrix to the value of the current iteration number, thereby marking its valid state; conversely, if the new position exceeds the boundary of the target drawing area, its value in the second state matrix will not be modified, which is equivalent to excluding the path from subsequent evolution and realizing the natural elimination of invalid branches.

[0151] During the above steps, each iteration generates a new set of target pixel positions, the total number of which is obtained by counting the number of elements in the second state matrix that have been updated to the current iteration number. This value represents the number of target pixel positions in a valid state after this iteration. The terminal device compares this number with the number of valid points recorded in the previous iteration: if they are not equal, it means that the fractal structure is still in the process of contraction or evolution and has not yet reached a stable form, so the next iteration needs to be performed; if they are equal, it means that after a complete transformation, the set of valid pixels has not changed, all retainable points have entered the cyclic mapping state, and the overall image tends to converge. At this point, it is determined that the invariant fractal image has been generated, the termination condition is met, and no further calculation is required.

[0152] The core concept of this embodiment lies in constructing an adaptive iterative control mechanism by introducing a convergence criterion based on pixel quantity stability. This mechanism does not rely on a fixed number of iterations or empirical thresholds, but rather dynamically monitors the actual results of state evolution, terminating the computation only when no further changes are confirmed, thus ensuring that the final image strictly satisfies the invariance requirement that "the pixel set no longer decreases." Simultaneously, by using alternating updates of two state matrices, separate management of data before and after iteration is achieved, avoiding logical conflicts caused by state overwriting. Therefore, this method not only improves the reliability and accuracy of the algorithm but also effectively suppresses redundant computation, optimizing overall performance while ensuring the accuracy of the results.

[0153] Please continue referring to the example above. During the m-th deterministic iteration, the terminal device can obtain the target pixel position with a value of m-1 from the first binary file s.txt, in order to ( For example, in which, Terminal devices can ( ) Restore the pixel coordinates (x, y) in the target drawing area, and then calculate the new pixel position based on (x, y) and the first spatial mapping relationship mentioned above. ).

[0154] If the new pixel position ( ) is located within the target drawing area, that is, If this is confirmed, the target pixel position is still valid after this iteration. Therefore, the target pixel position can be found in the second binary file t.txt. Write the iteration count m at the current location, and increment the number of target pixel positions after this iteration by 1. Set as Then, continue to obtain the position of the next target pixel with a value of m-1 and perform the above iteration until all target pixel positions with a value of m-1 have been iterated.

[0155] Understandable, if If the target pixel position is not valid after this iteration, then the target pixel position in the second binary file t.txt is not considered. Update the value at position m-1 so that it remains m-1.

[0156] After all target pixel positions with values ​​of m-1 have been iterated over, if If the iteration count is not met, it means the convergence has not occurred and another iteration is needed. In this case, the iteration count m can be updated to m+1, indicating that the (m+1)th iteration is about to begin. Set as The value and will The value is updated to 0, indicating that this iteration will be used as the previous iteration in the (m+1)th iteration. It is necessary to recount the number of target pixel positions and copy the contents of t.txt to s.txt to ensure that the contents of the two are consistent, so as to facilitate the (m+1)th iteration.

[0157] like If the iteration ends, the minimum number of iterations required to draw the invariant fractal is m-1, meaning the drawing time for m-1 iterations is the minimum drawing time for the invariant fractal.

[0158] It should be noted that when the minimum number of iterations is m-1, the m-th iteration only serves to verify convergence.

[0159] In this embodiment, if the terminal device determines to terminate the iteration, it can determine the pixel coordinates of each target pixel in the first state matrix in the drawing window through the second spatial mapping relationship, and draw points in the drawing window according to the pixel coordinates to obtain the generated fractal map.

[0160] In one possible implementation, this second space mapping relationship is represented by the following formula:

[0161]

[0162] Where i and j represent the pixel positions in the state matrix, and x and y represent the pixel coordinates of the pixel positions in the target drawing area. Characterizes the width of the drawing window. Characterizes the height of the drawing window. Characterizes the width of the target drawing area. Characterizes the height of the target drawing area.

[0163] It should be understood that after the deterministic iterative process is completed, the first state matrix has stably stored the positions of all valid pixels constituting the invariant fractal image. These positions exist in the form of matrix indices (i, j), which need to be mapped to the actual display coordinates (x, y) in the drawing window through coordinate transformation to complete the final image visualization. Therefore, a second spatial mapping relationship is introduced. Its function is to accurately convert the discrete data positions within the target drawing area into physical pixel coordinates in the drawing window, ensuring that the generated graphic maintains both geometric integrity and correct layout.

[0164] During the above steps, all elements in the first state matrix are traversed first, and the valid pixel positions (i, j) marked with the final iteration number are identified. For each such position, the coordinates are calculated according to the second spatial mapping formula.

[0165] The core concept of this embodiment lies in achieving a distortion-free transformation from internal state representation to external display coordinates through a well-defined and reversible second spatial mapping relationship. This process not only ensures drawing accuracy but also supports flexible adaptation to different sizes of drawing windows and target area combinations. Thus, this step completes the final connection from the algorithmic logic space to the user's visual interface, accurately restoring the abstract state information stored in the first state matrix into a set of pixels with spatial positioning significance, truly realizing the complete generation and accurate rendering of the invariant fractal map.

[0166] To further verify the effectiveness of the invariant fractal generation method provided in the embodiments of this application, the following explanation is provided in conjunction with the invariant fractal generation test.

[0167] The tests were conducted under specific hardware and software conditions to ensure the reproducibility and consistency of the experimental results. On the software side, Windows 7 was used as the development and runtime platform, with Microsoft Visual Studio 2008 as the integrated development environment and Microsoft Visual C++ 6.0 as the programming language. This combination provides excellent support for low-level memory operations and efficient numerical computation, facilitating accurate evaluation of the algorithm's performance. For hardware configuration, the test device was a Dell Vostro 220 PC, equipped with an Intel® Pentium® Dual-Core CPU with a clock speed of 2.70GHz, 2GB of DDR3 SDRAM memory, and a 320GB SATA hard drive (7200 RPM), constituting a typical low-to-mid-range computing environment that reflects the actual performance of the method under resource-constrained conditions.

[0168] To ensure a consistent evaluation benchmark, all test cases set the initial drawing area to 360×360 pixels, while the actual drawing area was dynamically adjusted based on the geometric characteristics of each fractal.

[0169] Table 1 shows the fractal parameters (IFS) for the first test case. Figure 3 This is a schematic diagram of the target rectangular area corresponding to the first test case. Figure 4 Table 1 shows the invariant fractal diagram corresponding to the first test case; Table 2 shows the fractal IFS parameters for the second test case. Figure 5 This is a schematic diagram of the target rectangular area corresponding to the second test case. Figure 6 Table 3 shows the invariant fractal diagram corresponding to the second test case; Table 3 shows the fractal diagram IFS parameters for the third test case. Figure 7 This is a schematic diagram of the target rectangular area corresponding to the third test case. Figure 8 Table 4 shows the invariant fractal diagram corresponding to the third test case; Table 5 shows the iterative performance analysis table for the first test case; Table 6 shows the iterative performance analysis table for the third test case; and Table 7 shows the initial drawing area influence analysis table.

[0170] Table 1

[0171]

[0172] Table 2

[0173]

[0174] Table 3

[0175]

[0176] Table 4

[0177]

[0178] Table 5

[0179]

[0180] Table 6

[0181]

[0182] Table 7

[0183]

[0184] Please refer to the above diagrams and tables.

[0185] The first test case generated a fractal structure based on a set of four-transform IFS codes. A random iterative probing method determined its minimum bounding rectangle to be a rectangular region with a width of 192 and a height of 361. A deterministic iterative process was then executed based on this. Experimental data showed that when the number of iterations reached 38, the number of effective pixels decreased from 14,374 in the 37th iteration to 14,373 and then remained unchanged, indicating that the graphic had entered a stable state. The corresponding shortest drawing time was 0.841 seconds. The second test case used a two-transform IFS system, with a minimum bounding rectangle of 361 width and 226 height. Its convergence speed was faster, requiring only 23 iterations to achieve pixel set stability, with a final effective pixel count of 32,149, taking 0.326 seconds. The third test case also included four transformation functions, probing a rectangular region of 361 width and 331 height. This fractal structure converged after the 16th iteration, at which point the total number of pixels stabilized at 10,064, requiring 0.483 seconds to draw.

[0186] A comprehensive analysis of the above results shows that the invariant fractal generation method provided in this application can stably generate invariant fractal images under IFS encoding of different complexities, and accurately identify the minimum number of iterations required to achieve image invariance.

[0187] Further examination of the impact of the initial drawing region size on performance revealed a significant increase in computation time as the target region expanded from 400×400 to 800×800, rising from 1.089 seconds to 4.790 seconds. This indicates a positive correlation between computational resource consumption and image size. However, the optimal number of iterations did not monotonically increase with size, but fluctuated between 38 and 54, reflecting that this parameter is primarily influenced by the fractal structure itself rather than simply resolution. Simultaneously, pixel density gradually decreased with increasing region size, indicating a reduction in information density per unit area. Overall, the experiments validated that this method maintains strict consistency in the generated results while exhibiting good efficiency controllability, and its performance conforms to expected patterns, providing a reliable basis for subsequent optimization.

[0188] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of an invariant fractal generation apparatus is given below. Optionally, the invariant fractal generation apparatus can employ the methods described above. Figure 1 The device structure of the terminal device is shown. Further, please refer to... Figure 9 , Figure 9 This is a functional block diagram of an invariant fractal graph generation device provided in an embodiment of this application. It should be noted that the basic principle and technical effects of the invariant fractal graph generation device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The invariant fractal graph generation device includes: a generation module and an iteration module.

[0189] The generation module is used to determine the target drawing region corresponding to the fractal image to be generated based on the IFS encoding of the fractal image to be generated and the initial drawing region, and to generate the state matrix corresponding to the target drawing region. The state matrix is ​​used to characterize whether each pixel in the target drawing region belongs to the valid state of the fractal image to be generated under different iterations, and the state matrix includes a first state matrix and a second state matrix with the same structure.

[0190] Understandably, this generation module can also be used to perform the above step S20.

[0191] This iterative module is used to perform deterministic iteration on the pixel positions in the state matrix. For each deterministic iteration, the target pixel positions that are in a valid state after the previous iteration are obtained from the first state matrix. Based on the first spatial mapping relationship between the target drawing area and the state matrix in the current iteration, the positions of each target pixel are deterministically iterated to obtain new pixel positions.

[0192] Understandably, this iterative module can also be used to perform step S21 as described above.

[0193] The iterative module is also used to update the valid state of each target pixel position in the second state matrix based on whether the new pixel position corresponding to each target pixel position is located within the target drawing area, and to determine whether to continue the deterministic iteration of the pixel positions in the state matrix based on whether the number of target pixel positions in the valid state after this iteration is the same as the number of target pixel positions in the valid state after the previous iteration.

[0194] Understandably, this iterative module can also be used to perform step S22 as described above.

[0195] The iterative module is also used to copy the data in the second state matrix to the first state matrix and continue to execute the next deterministic iteration if the deterministic iteration of the pixel positions in the state matrix continues.

[0196] Understandably, this iterative module can also be used to perform step S23 above.

[0197] The iterative module is also used to generate a fractal image to be generated in the drawing window if the deterministic iteration of the pixel positions in the state matrix is ​​terminated, based on the first state matrix and the second spatial mapping relationship between the target drawing area and the state matrix.

[0198] Understandably, this iterative module can also be used to perform step S24 above.

[0199] Optionally, the generation module is further configured to determine the minimum bounding rectangle of the fractal image to be generated based on the IFS parameters of the fractal image to be generated using a random iterative probing method; calculate the target scaling factor based on the minimum bounding rectangle and the initial drawing area; determine the target drawing area based on the target scaling factor and the minimum bounding rectangle; and generate a state matrix based on the target drawing area.

[0200] Optionally, the generation module is further configured to calculate the horizontal coordinate scaling factor based on the minimum and maximum horizontal coordinates of the minimum bounding rectangle and the width of the initial drawing area, and to calculate the vertical coordinate scaling factor based on the minimum and maximum vertical coordinates of the minimum bounding rectangle and the height of the initial drawing area; determine the minimum of the horizontal and vertical coordinate scaling factors as the target scaling factor; calculate the width of the target drawing area based on the minimum and maximum horizontal coordinates and the target scaling factor, and calculate the height of the target drawing area based on the minimum and maximum vertical coordinates and the target scaling factor to determine the target drawing area; generate a state matrix based on the width and height of the target drawing area, and perform effective state initialization on the position of each pixel in the state matrix.

[0201] Optionally, the iterative module is further configured to determine the position of the pixel in the first state matrix that has the same number as the previous iteration as the target pixel position; for each target pixel position, determine the pixel coordinates of the target pixel position in the target drawing area, and determine the new pixel position according to the pixel coordinates and the first spatial mapping relationship under the current iteration.

[0202] Optionally, the iterative module is further configured to, for each target pixel location, update the value at the target pixel location in the second state matrix to the value of the current iteration number if the new pixel location corresponding to the target pixel location is located within the target drawing area, to indicate that the target pixel location is still in a valid state after the current iteration; if the new pixel location corresponding to the target pixel location is not located within the target drawing area, the value at the pixel location in the second state matrix is ​​not updated, to indicate that the pixel location is in an invalid state after the current iteration; if the number of target pixel locations in a valid state after the current iteration is different from the number of target pixel locations in a valid state after the previous iteration, then the deterministic iteration of the pixel locations in the state matrix continues; if the number of pixel locations in a valid state after the current iteration is the same as the number of pixel locations in a valid state after the previous iteration, then the deterministic iteration of the pixel locations in the state matrix is ​​terminated.

[0203] Optionally, the iterative module is also used to determine the pixel coordinates of each target pixel in the first state matrix in the drawing window through the second spatial mapping relationship, and to draw points in the drawing window according to the pixel coordinates to obtain the generated fractal map;

[0204] The second spatial mapping relationship is represented by the following formula:

[0205]

[0206] Where i and j represent the pixel positions in the state matrix, and x and y represent the pixel coordinates of the pixel positions in the target drawing area. Characterizes the width of the drawing window. Characterizes the height of the drawing window. Characterizes the width of the target drawing area. Characterizes the height of the target drawing area.

[0207] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown is either stored in or embedded in the operating system (OS) of the terminal device, and can be used by... Figure 1 The processor executes the commands. Meanwhile, the data and program code required to execute these modules can be stored in memory.

[0208] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, can implement the invariant fractal generation method provided in this application.

[0209] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0210] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0211] If a function is implemented as a software module and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0212] The above are merely preferred embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for generating an invariable fractal figure, characterized by, The method comprises: According to the IFS code and the initial drawing area of the fractal image to be generated, a target drawing area corresponding to the fractal image to be generated is determined, and a state matrix corresponding to the target drawing area is generated; Wherein, the state matrix is used to represent whether each pixel point in the target drawing area belongs to the effective state of the fractal image to be generated under different iteration times, and the state matrix includes a first state matrix and a second state matrix with the same structure; Deterministic iteration is performed on the pixel point positions in the state matrix, and for each deterministic iteration, the target pixel point positions in the effective state after the last iteration are obtained from the first state matrix, and the deterministic iteration is performed on each target pixel point position according to the first spatial mapping relationship between the target drawing area and the state matrix under this iteration, to obtain new pixel point positions; The first spatial mapping relationship is represented by the following formula: wherein , , , ; i, j represent pixel point positions in the state matrix, , , , , , respectively represent iteration parameters under this iteration, k represents the kth iteration function, and , represents the minimum value of the horizontal coordinate of the minimum enclosing rectangle, , y represents pixel point coordinates of the pixel point positions in the state matrix in the target drawing area, and the pixel point coordinates are determined through a second spatial mapping relationship, represents the minimum value of the vertical coordinate of the minimum enclosing rectangle, represents the horizontal coordinate scaling factor, represents the vertical coordinate scaling factor, represents the target scaling factor, represents the horizontal coordinate offset, represents the vertical coordinate offset, represents the width of the target drawing area, represents the height of the target drawing area, represents the maximum value of the horizontal coordinate of the minimum enclosing rectangle, represents the maximum value of the vertical coordinate of the minimum enclosing rectangle; According to whether the new pixel point positions corresponding to each target pixel point position are located in the target drawing area, the effective state of each target pixel point position in the second state matrix is updated, and according to whether the number of target pixel point positions in the effective state after this iteration is the same as the number of target pixel point positions in the effective state after the last iteration, it is determined whether to continue the deterministic iteration on the pixel point positions in the state matrix; If the deterministic iteration on the pixel point positions in the state matrix is continued, the data in the second state matrix is copied to the first state matrix, and the next deterministic iteration is continued; If the deterministic iteration on the pixel point positions in the state matrix is terminated, the pixel point coordinates of each target pixel point position in the drawing window are determined through the second spatial mapping relationship, the point drawing is performed in the drawing window according to the pixel point coordinates, and the generated fractal image is obtained; Wherein, the second spatial mapping relationship is represented by the following formula: wherein, characterizes a width of the plot window, characterizes a height of the plot window.

2. The method of claim 1, wherein, According to the IFS parameters and the initial drawing area of the fractal image to be generated, the target drawing area corresponding to the fractal image to be generated is determined, and the state matrix corresponding to the target drawing area is generated, comprising: According to the IFS parameters of the fractal image to be generated, the minimum enclosing rectangle of the fractal image to be generated is determined based on the random iteration detection method; According to the minimum enclosing rectangle and the initial drawing area, a target scaling factor is calculated, the target drawing area is determined according to the target scaling factor and the minimum enclosing rectangle, and the state matrix is generated according to the target drawing area.

3. The method of claim 2, wherein, According to the minimum enclosing rectangle and the initial drawing area, a target scaling factor is calculated, the target drawing area is determined according to the target scaling factor and the minimum enclosing rectangle, and the state matrix is generated according to the target drawing area. calculating a horizontal coordinate scaling factor according to a horizontal coordinate minimum value, a horizontal coordinate maximum value of the minimum enclosing rectangle and a width of the initial drawing area, and calculating a vertical coordinate scaling factor according to a vertical coordinate minimum value, a vertical coordinate maximum value of the minimum enclosing rectangle and a height of the initial drawing area; determining a minimum value of the horizontal coordinate scaling factor and the vertical coordinate scaling factor as the target scaling factor; calculating a width of the target drawing area according to the horizontal coordinate minimum value, the horizontal coordinate maximum value and the target scaling factor, and calculating a height of the target drawing area according to the vertical coordinate minimum value, the vertical coordinate maximum value and the target scaling factor, to determine the target drawing area; generating the state matrix according to the width and the height of the target drawing area, and initializing effective states of pixel positions in the state matrix.

4. The method of claim 1, wherein, the target pixel positions in the first state matrix after the last iteration are determined according to a first spatial mapping relationship between the target drawing area in this iteration and the state matrix, and each of the target pixel positions is determined iteratively to obtain a new pixel position, including: the pixel positions in the first state matrix with the same number of iteration times as the last iteration are determined as the target pixel positions; for each of the target pixel positions, a pixel coordinate of the target pixel position in the target drawing area is determined, and the new pixel position is determined according to the pixel coordinate and the first spatial mapping relationship in this iteration.

5. The method of claim 1, wherein, the effective states of each of the target pixel positions in the second state matrix are updated according to whether the new pixel position corresponding to each of the target pixel positions is located in the target drawing area, and whether to continue the iterative determination of the pixel positions in the state matrix is determined according to whether the number of target pixel positions in the effective state after this iteration is the same as the number of target pixel positions in the effective state after the last iteration, including: for each of the target pixel positions, if the new pixel position corresponding to the target pixel position is located in the target drawing area, the value of the target pixel position in the second state matrix is updated to the value of the number of iteration times in this iteration, to identify that the target pixel position is still in the effective state after this iteration; if the new pixel position corresponding to the target pixel position is not located in the target drawing area, the value of the pixel position in the second state matrix is not updated, to identify that the pixel position is in the invalid state after this iteration; if the number of target pixel positions in the effective state after this iteration is not the same as the number of target pixel positions in the effective state after the last iteration, the iterative determination of the pixel positions in the state matrix is continued; if the number of pixel positions in the effective state after this iteration is the same as the number of pixel positions in the effective state after the last iteration, the iterative determination of the pixel positions in the state matrix is terminated.

6. An invariable fractal pattern generating apparatus, characterized by comprising: The device comprises: A generating module configured to determine a target drawing area corresponding to the fractal image to be generated according to IFS coding and an initial drawing area of the fractal image to be generated, and generate a state matrix corresponding to the target drawing area; The state matrix is used to represent whether each pixel point in the target drawing area belongs to an effective state of the fractal image to be generated at different iteration times, and the state matrix comprises a first state matrix and a second state matrix with the same structure; An iteration module configured to perform deterministic iteration on pixel point positions in the state matrix, for each deterministic iteration, acquire target pixel point positions in an effective state after last iteration from the first state matrix, perform deterministic iteration on each target pixel point position according to a first spatial mapping relationship between the target drawing area and the state matrix at this iteration, and obtain new pixel point positions; the first spatial mapping relationship is represented by the following formula: wherein , , , ; i, j represent pixel point positions in the state matrix, , , , , , respectively represent iteration parameters under this iteration, k represents the kth iteration function, and , represents the minimum value of the horizontal coordinate of the minimum enclosing rectangle, , y represents pixel point coordinates of the pixel point positions in the state matrix in the target drawing area, and the pixel point coordinates are determined through a second space mapping relationship, represents the minimum value of the vertical coordinate of the minimum enclosing rectangle, represents the horizontal coordinate scaling factor, represents the vertical coordinate scaling factor, represents the target scaling factor, represents the horizontal coordinate offset, represents the vertical coordinate offset, represents the width of the target drawing area, represents the height of the target drawing area, represents the maximum value of the horizontal coordinate of the minimum enclosing rectangle, represents the maximum value of the vertical coordinate of the minimum enclosing rectangle; The iteration module is further configured to update the effective state of each target pixel point position in the second state matrix according to whether the new pixel point position corresponding to each target pixel point position is located in the target drawing area, and determine whether to continue deterministic iteration on the pixel point positions in the state matrix according to whether the number of target pixel point positions in an effective state after this iteration is the same as the number of target pixel point positions in an effective state after last iteration; The iteration module is further configured to, if the deterministic iteration on the pixel point positions in the state matrix is continued, copy data in the second state matrix to the first state matrix, and continue next deterministic iteration; The iteration module is further configured to, if the deterministic iteration on the pixel point positions in the state matrix is terminated, determine pixel point coordinates of each target pixel point position in the first state matrix in a drawing window through a second spatial mapping relationship, perform point drawing in the drawing window according to the pixel point coordinates, and obtain the generated fractal image; The second spatial mapping relationship is represented by the following formula: wherein, characterizes a width of the plot window, characterizes a height of the plot window.

7. A terminal device, characterized by, A processor and a memory, the memory stores a computer program capable of being executed by the processor, and the processor is configured to execute the computer program to implement the method in any one of claims 1-5.

8. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the method in any one of claims 1-5.

Citation Information

Patent Citations

  • Fractal graph drawing method and device, storage medium and electronic equipment

    CN120032022A