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

By iterating the fractal chart and judging the change in the number of pixels, the problem of lack of scientificity in the clarity judgment of fractal charts in the prior art is solved, and a more objective clarity evaluation and resource optimization are achieved.

CN120032022AActive Publication Date: 2025-05-23WUHAN POLYTECHNIC UNIVERSITY

Patent Information

Application Number
CN202510498085.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-05-23
Estimated Expiration
2045-04-21

AI Technical Summary

Technical Problem

In the prior art, the judgment of the clarity of fractal charts mainly depends on naked eye observation, lacks scientificity, and the clarity of fractal charts may have reached its limit after the number of iterations increases, but iteration still needs to be continued, resulting in wasted computing resources.

Method used

By iterating the current basic fractal chart by presetting the number of times, we obtain the derived fractal chart and judge whether the number of pixels required to generate the fractal chart has changed compared to the basic fractal chart. If it changes, the derivative fractal chart continues to iterate as the new base fractal chart; if it does not change, it is used as the target fractal chart and iterates to stop iterating.

Benefits of technology

It is determined whether the fractal chart reaches the optimal clarity by changing the number of pixels before and after iteration, and judge the clarity of the fractal chart more objectively than the naked eye observation, avoiding unnecessary waste of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120032022A_ABST
    Figure CN120032022A_ABST
Patent Text Reader

Abstract

The invention provides a fractal graph drawing method and device, a storage medium and electronic equipment, and relates to the field of computer graphics. The method comprises the following steps: the electronic equipment iterates a preset number of times by utilizing a current basic fractal graph to obtain a derivative fractal graph; judging whether the number of pixels required for displaying the derivative fractal graph is changed or not compared with the current basic fractal graph; if the derivative fractal graph will change, taking the derivative fractal graph as a new basic fractal graph, and returning to the step of obtaining the derivative fractal graph by utilizing the current basic fractal graph to carry out iteration for preset times; and if the fractal graph does not change, taking the derivative fractal graph as a target fractal graph. Thus, whether the fractal graph reaches the optimal definition or not is judged by judging whether the number of pixels before and after iteration changes, and compared with visual inspection, the definition of the fractal graph can be judged more objectively.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer graphics, and in particular to a method, device, storage medium and electronic device for drawing a fractal image. Background Art

[0002] Fractals are graphics generated by iterative algorithms in mathematics. In the process of generating fractals, simple rules or formulas are repeatedly applied, and each iteration adds details to the previous one, thus creating complex patterns with self-similar characteristics. These patterns can be seen to have a similar structure to the whole when any part is enlarged.

[0003] In order to draw a clearer fractal graph, more function iterations are usually required. In theory, the more iterations there are, the clearer the fractal graph will be. However, the current judgment of the clarity of fractal graphs mainly relies on naked eye observation, which is obviously unscientific. Specifically, two fractal graphs that appear to have the same clarity may actually have significant differences. Summary of the invention

[0004] In order to overcome at least one of the deficiencies in the prior art, the present application provides a fractal image drawing method, device, storage medium and electronic device, specifically including: In a first aspect, the present application provides a method for drawing a fractal image, the method comprising: Iterate the current basic fractal graph for a preset number of times to obtain a derived fractal graph; Determining whether a number of pixels required to display the derived fractal image will change compared to the current base fractal image; If there is a change, the derived fractal graph is used as a new basic fractal graph, and the process returns to the step of iterating the current basic fractal graph a preset number of times to obtain a derived fractal graph; If no change occurs, the derived fractal graph is used as the target fractal graph.

[0005] In a second aspect, the present application provides a fractal image drawing device, the device comprising: A fractal graph module, used to iterate the current basic fractal graph for a preset number of times to obtain a derived fractal graph; A clarity module, for determining whether the number of pixels required to display the derived fractal image will change compared to the current base fractal image; The clarity module is further configured to use the derived fractal image as a new basic fractal image if there is a change, and return to the step of iterating the current basic fractal image a preset number of times to obtain the derived fractal image; The clarity module is further configured to use the derived fractal graph as a target fractal graph if no change occurs.

[0006] In a third aspect, the present application provides a storage medium storing a computer program, which, when executed by a processor, implements the fractal image drawing method.

[0007] In a fourth aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the fractal image drawing method is implemented.

[0008] Compared with the prior art, this application has the following beneficial effects: The present application provides a fractal image drawing method, device, storage medium and electronic device. Among them, the electronic device iterates the current basic fractal image for a preset number of times to obtain a derived fractal image; determines whether the number of pixels required to display the derived fractal image will change compared to the current basic fractal image; if it will change, the derived fractal image is used as a new basic fractal image, and returns to the step of iterating the current basic fractal image for a preset number of times to obtain the derived fractal image; if it will not change, the derived fractal image is used as the target fractal image. In this way, whether the fractal image has achieved the best clarity is determined by whether the number of pixels before and after the iteration changes. Compared with naked eye observation, the clarity of the fractal image can be judged more objectively. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0010] Figure 1 A schematic diagram of a fractal image drawing method provided in an embodiment of the present application; Figure 2 One of the detailed schematic diagrams of the process of the fractal image drawing method provided in the embodiment of the present application; Figure 3 A second schematic diagram of the process details of the fractal image drawing method provided in an embodiment of the present application; Figure 4 The first experimental fractal graph with different step lengths is drawn using a two-dimensional matrix memorandum method provided in an embodiment of the present application; Figure 5 The first experimental fractal graph under different step length control is drawn using the binary sorting tree memorandum method provided in the embodiment of the present application; Figure 6The first experimental fractal graph with different iteration times drawn by random iteration method provided in the embodiment of the present application; Figure 7 A second experimental fractal graph with different step lengths drawn using a two-dimensional matrix memorandum method provided in an embodiment of the present application; Figure 8 A second experimental fractal graph under different step length control is drawn using a binary sorting tree memorandum method provided in an embodiment of the present application; Fig. 9 The second experimental fractal graph of the random iteration method provided in the embodiment of the present application at different iteration times; Fig.10 A schematic diagram of the structure of a fractal image drawing device provided in an embodiment of the present application; Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0011] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0012] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0013] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0014] In the description of the present application, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. In addition, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0015] Based on the above statement, as introduced in the background technology, the current judgment of the clarity of fractal images mainly relies on naked eye observation, which is obviously unscientific. Specifically, in order to draw a clearer fractal image, more iterative operations are usually required, and the iterated fractal image is displayed in real time in the drawing area of ​​the screen. After the user's naked eye feels clear enough, the iteration is stopped. This method not only lacks scientific basis, but also requires repeated drawing to display the iterated fractal image in real time, which will also lead to a waste of computing resources and increased time consumption.

[0016] Based on the discovery of the above technical problems, the inventors have proposed the following technical solutions to solve or improve the above problems through creative work. It should be noted that the defects in the solutions in the above prior art are the results obtained by the inventors after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the embodiments of the present application for the above problems below should all be the contributions made by the inventors to the present application in the process of invention and creation, and should not be understood as technical contents known to those skilled in the art.

[0017] Research has found that, although in theory the more iterations there are, the higher the clarity of the fractal image. However, in practical applications, due to the limitation of the display resolution, when the number of iterations reaches a certain threshold, the clarity of the fractal image will reach its limit. At this point, further increasing the number of iterations will not increase the number of pixels or the visual effect of the image. Based on the above findings, the present embodiment (hereinafter referred to as the present embodiment) provides a method for drawing a fractal image. Figure 1 As shown, the method includes: S1, iterating the current basic fractal graph a preset number of times to obtain a derived fractal graph.

[0018] S2, judging whether the number of pixels required to display the derived fractal image has changed compared to the current basic fractal image. If so, executing S3, otherwise, executing S4.

[0019] S3, taking the derived fractal graph as a new basic fractal graph, and returning to step S1.

[0020] S4, the derived fractal graph is used as the target fractal graph.

[0021] In this way, whether the fractal image has reached a certain clarity can be judged by whether the number of pixels before and after iteration changes. Compared with naked eye observation, the clarity of the fractal image can be judged more objectively.

[0022] In addition, it should be understood that the electronic device implementing the fractal drawing method in this embodiment may be, but is not limited to, a mobile terminal, a tablet computer, a laptop computer, a desktop computer, and a server, etc. The server may be a single server or a server group. The server group may be centralized or distributed (for example, the server may be a distributed system). In some embodiments, the server may be local or remote relative to the user terminal. In some embodiments, the server may be implemented on a cloud platform; as an example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an inter-cloud, a multi-cloud, etc., or any combination thereof. In some embodiments, the server may be implemented on an electronic device having one or more components.

[0023] To make the solution described below easier to understand, the symbols that may be used in this embodiment are explained below:

[0024] The following describes in detail the concepts that may be involved in this embodiment: IFS code, IFS code is a set of functions used to describe and generate fractal images. Each function has a corresponding probability weight, which determines the probability of selecting different transformations during each iteration. In this way, the generation process and final form of the fractal image can be precisely controlled. For example, when generating the famous Barnsley fern fractal, the IFS code usually contains four affine transformations, each with a different probability weight. These transformations can generate very realistic fern leaf patterns through specific parameter combinations. In practical applications, the IFS code first defines the mathematical expressions of these transformations, and then implements the iterative application of these transformations through programming. At each iteration, one of the transformations is selected and applied to the current point to generate a new point. These new points are gradually accumulated to eventually present a complete fractal pattern.

[0025] Random iteration is an important method for generating fractal images. Its core lies in the definition and application of IFS code. IFS code contains a set of affine transformation functions, each of which is equipped with a corresponding probability value, which determines the possibility of selecting a certain transformation function in each iteration. Specifically, in each iteration, the electronic device selects a transformation function from the IFS code in a random manner according to these probability values ​​and applies it to the current point to generate a new point. By repeating this process continuously, these new points gradually accumulate and eventually present a complete fractal pattern. Taking the classic Barnsley fern leaf as an example, its IFS code usually contains four affine transformation functions, each with different probability weights. These transformation functions cooperate with each other through specific mathematical parameters (such as translation, rotation and scaling) to gradually generate details such as the trunk, side branches and leaves of the fern leaf, and finally form a highly realistic fern leaf shape.

[0026] The fractal points on the fractal graph refer to the points generated based on the Iterated Function System (IFS), which together constitute the complex original fractal graph. These fractal points are located on a virtual two-dimensional plane, generated through multiple iterations, and finally presented on the screen. It can be understood as the original fractal graph, whose clarity is greater than or equal to the fractal graph displayed on the screen.

[0027] The fractal points in the drawing area refer to the fractal pixel points actually drawn in the user-specified drawing window after the original fractal image is zoomed and translated. When generating a fractal image, the original fractal image may be very large or have infinite details, so it is necessary to map it to a specific sub-area, namely the drawing area, through zooming and translation operations. This drawing area is determined according to the user's window settings to ensure that the fractal image can fit and be clearly displayed in the limited screen space.

[0028] Points on a two-dimensional matrix refer to points stored in the computer memory for recording drawing status. A two-dimensional matrix is ​​essentially a two-dimensional array, and each element represents a pixel in the drawing area. If the value of the element is 1, it means that the pixel has been used; if it is 0, it means that it has not been used. The points on the two-dimensional matrix correspond one-to-one to the points in the drawing area, but they are located in the computer memory, which can be used to increase the drawing speed and avoid repeated drawing.

[0029] Based on the above description, a desktop computer is used as an electronic device to implement the fractal drawing method. Figure 1 However, it should be understood that the operations of the flowchart may not be implemented in order, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowchart, or remove one or more operations from the flowchart, under the guidance of the content of this application. Figure 1 , the method comprising: S1, iterating the current basic fractal graph a preset number of times to obtain a derived fractal graph.

[0030] It should be understood that the preset number of times can be 1 or more times, which is referred to as a step length in this embodiment. It can be understood that within each step length, the basic fractal image will be iterated for a preset number of times. For example, assuming that the preset number of times is 100 times, 10 step lengths means that 100*10=1000 iterations are performed.

[0031] Since the generation of a fractal graph is usually based on a simple initial graph or rule, a more complex pattern is gradually generated by repeatedly iterating this rule. Therefore, the more iterations there are, the richer the details of the fractal graph are. In this embodiment, for each step length, the fractal graph to be iterated is called a basic fractal graph, and the fractal graph iterated by a step length is called a derived fractal graph. It can be understood that the basic fractal graph can be a fractal graph in the initial stage, or a fractal graph iterated by a certain step length. The basic fractal graph will change after each iteration of a step length.

[0032] In addition, within each step, each iteration means generating new pixels and geometric shapes through specific mathematical rules and iterative function systems (IFS), thus forming a new fractal image.

[0033] It should also be understood that the derived fractal image can be obtained by growing the current basic fractal image, that is, the growing iterative drawing method. It can be understood that the growing iterative method is to build a fractal image by gradually adding pixels, usually starting from a simple initial shape, and increasing details and complexity by continuously applying transformation rules until the desired fractal structure is reached.

[0034] S2, determining whether the number of pixels required to display the derived fractal image will change compared to the current basic fractal image.

[0035] If yes, execute S3, otherwise execute S4.

[0036] S3, taking the derived fractal graph as a new basic fractal graph, and returning to step S1.

[0037] S4, the derived fractal graph is used as the target fractal graph.

[0038] In this regard, it can be understood that as the number of iterations increases, the fractal image will become clearer and clearer, and the number of pixels required for display will also increase synchronously. When a certain critical point is reached, the number of newly added pixels becomes negligible, which indicates that the clarity of the fractal image has reached the limit of what the screen can display. Therefore, further iterations will not significantly increase the number of new pixels, and eventually the number of pixels in the drawing area will no longer increase.

[0039] Therefore, through the above implementation, after each step iteration, if it is found that the pixel showing the current derived fractal image no longer changes, the derived fractal image is identified as the target fractal image and no further iteration is performed. In this way, it is ensured that the fractal image stops iterating when the optimal complexity is reached, which not only avoids unnecessary waste of computing resources, but also ensures the quality of the final fractal image.

[0040] The above implementation introduces the principle of the growing iterative drawing method. Figure 2 As shown, when the derived fractal graph is grown by the current basic fractal graph, Figure 1 Step S2 in the method may include: S2-1, obtaining the newly added fractal points generated by the derived fractal graph.

[0041] Among them, the newly added fractal point represents the difference between the derived fractal graph and the previous basic fractal graph after one step of iteration.

[0042] S2-2, determining the target position of the newly added fractal point in the memo.

[0043] The memo is used to record the usage statistics of each pixel in the drawing area. It should be understood that the above-mentioned basic fractal image and the derived fractal image are both original fractal images located on a virtual two-dimensional plane. To display these fractal images in the drawing area of ​​the screen, a series of mappings are required. Therefore, in the mapping process, this embodiment uses the memo to count which pixels have been used and which have not been used.

[0044] As an optional implementation, the desktop computer can obtain a first mapping relationship between the derived fractal image and the two-dimensional matrix; use the first mapping relationship to map the position of the newly added fractal point in the derived fractal image to the array position in the two-dimensional matrix; and determine the array position as the target position of the newly added fractal point in the memo.

[0045] It can be understood that the memo actually implements a two-dimensional matrix through a two-dimensional array in memory, and the array records the usage statistics of each pixel in the drawing area. For example, when a pixel has been used, the corresponding position in the two-dimensional matrix is ​​marked as 1, otherwise, it is marked as 0. By querying and updating this two-dimensional array, each pixel is drawn only once when drawing a fractal image in the drawing area later, thereby improving the drawing efficiency of the fractal image.

[0046] It should also be understood that before querying the memo, the newly added fractal points need to be mapped into a two-dimensional matrix, so it is necessary to obtain the mapping relationship between them, which is referred to as the first mapping relationship in this embodiment.

[0047] In this regard, in this embodiment, the desktop computer can first generate an exploratory fractal graph, wherein the number of iterations of the exploratory fractal graph is less than the number of iterations required to obtain the target fractal graph; obtain a scaling factor according to the size of the exploratory fractal graph and the size of the drawing area; and obtain a first mapping relationship according to the scaling factor. The first mapping relationship is used to map the fractal points in the fractal graph to a two-dimensional matrix. In addition, a second mapping relationship can also be obtained through the scaling factor, and the second mapping relationship is used to map the fractal points in the fractal graph to the drawing area.

[0048] Thus, before formally performing iteration, this embodiment may perform a small amount of iterations to obtain the initial position and drawing area of ​​the fractal image, thereby optimizing the subsequent calculation and drawing process.

[0049] For example, the desktop computer first detects the width of the drawing window. and high As part of the drawing window, the drawing area cannot exceed the drawing window. He Gaowei If a fractal image is drawn in a rectangular area, the drawing area The initial space is expressed as:

[0050] Fractal Iterated Function System The iterative function is expressed as follows: , ,

[0051] If the probability , then the iterated function set in the fractal graph is The iterative probability interval of a function The calculation is as follows: ,

[0052] Therefore, if the points on the fractal graph are known , then the next point Determined by the following piecewise function:

[0053] Considering that the fractal graph will continue to grow in a specific direction during the iteration process, and different types of fractal graphs have different growth directions, it is necessary to first obtain the approximate display range of the fractal graph in the drawing area. In addition, in the process of drawing the fractal graph, the selection of the initial point is very important. The initial point determines the direction of subsequent iterations and the distribution of the graph. Therefore, a reasonable initial point can help generate a more uniform and representative fractal graph. To this end, you can first make Then, the desktop computer uses the above iterative formula to randomly iterate 20 times to obtain the new initial point of the fractal graph. , and With this new starting point, conditions are created for the subsequent estimation of the drawing area and the drawing of the fractal graph.

[0054] To obtain the drawing area , , and , you can continue at the new starting point On the basis of , the random iteration is continued for 500 times, so that the plane coordinates of each fractal point on the fractal graph in the drawing area are obtained. It can be understood that 500 times is a more reasonable number of iterations obtained after a large number of experiments. Of course, the technicians can make appropriate adjustments when implementing this solution.

[0055] After the fractal iterative function system is iterated, the maximum value of the horizontal coordinate of the pixel point is The calculation is as follows:

[0056] After the fractal iterative function system is iterated, the minimum value of the horizontal coordinate of the pixel point The calculation is as follows:

[0057] After the fractal iterative function system is iterated, the maximum value of the vertical coordinate of the pixel point is The calculation is as follows:

[0058] After the fractal iterative function system is iterated, the minimum value of the vertical coordinate of the pixel point The calculation is as follows:

[0059] It should be noted that, although the greater the number of iterations, the more accurate the obtained drawing area is, the longer the time spent is, so it is more reasonable to set the number of iterations to 500. Of course, the inventors who implement this application can adaptively adjust the number of iterations.

[0060] With the maximum value of the horizontal coordinate of the pixel point and minimum value , you can get the scaling factor of the horizontal axis in the drawing area The calculation is as follows:

[0061] With the maximum value of the vertical coordinate of the pixel point and minimum value , you can get the scaling factor of the ordinate in the drawing area The calculation is as follows:

[0062] In order to ensure that the fractal image has the same aspect ratio, the image scaling factor The calculation is as follows:

[0063] Width of the drawing area and high Recalculate as follows:

[0064] In order to center the fractal image horizontally in the drawing window, the horizontal coordinate offset of the point on the fractal image The calculation is as follows:

[0065] In order to make the fractal image vertically centered in the drawing window, the vertical coordinate offset of the points on the fractal image The calculation is as follows:

[0066] Fractal points on fractal graphics The horizontal coordinate in the two-dimensional matrix can be obtained by using the following first mapping relationship: and :

[0067] The fractal points on the fractal graph The following second mapping relationship can be used to obtain the horizontal coordinate in the drawing area: And the vertical axis , so that the fractal point is displayed at the corresponding position in the drawing area:

[0068]

[0069] Based on the above example, a new initial point, a first mapping relationship and a second mapping relationship are obtained. The desktop computer represents the number of iterations. After initialization to 0, iterate again to get the desired fractal image.

[0070] In this way, a two-dimensional matrix of the same size as the drawing area is used to count whether each pixel has been used. Every time the desktop computer tries to draw a new pixel, it checks the corresponding array position. If the array position has been marked as 1 (indicating that the pixel has been used), the desktop computer will skip this counting operation. Conversely, if the array position is not marked, the desktop computer will draw the pixel and mark the corresponding two-dimensional matrix position as 1. This method ensures that each pixel is drawn only once, avoiding the additional overhead caused by repeated drawing.

[0071] In other optional implementations, it is found in practice that when drawing a larger fractal image, the two-dimensional matrix needs to occupy a large amount of continuous memory space. If the memory management system cannot provide a large enough continuous memory block, it will be impossible to count which pixels have been used through the two-dimensional matrix.

[0072] In this regard, the memo can also be a binary tree converted from a two-dimensional matrix of the same size as the drawing area. The desktop computer can map the position of the newly added fractal point in the derived fractal image to the two-dimensional matrix to obtain the array position of the newly added fractal point in the two-dimensional matrix; convert the array position into an index value of the binary tree; and determine the index value as the target position of the newly added fractal point in the memo.

[0073] For example, the data structure of a binary tree can be defined as struct node{int key;struct node *lchild,*rchild}. It is not difficult to see from the data structure that each node contains an integer key "key" and pointers to the left child node "lchild" and the right child node "rchild". In this way, this structure allows efficient insertion and search of data through binary search.

[0074] According to the indexing principle of a binary tree, the index of a binary tree requires an index value. In this regard, in this embodiment, the desktop computer can use the length or width of the drawing area as a weight; weight the coordinate values ​​of the array position according to the weight to obtain the index value of the binary tree.

[0075] For example, assuming that the array position is represented as , the long use of the drawing area To indicate that the drawing area is high To represent, the index value It can be calculated by the following expression:

[0076] or

[0077] Based on the above implementation, the method of drawing the derived fractal graph is described. Figure 2 , step S2 further includes: S2-3, determine whether the target position marks a record that has been used. If not, it means that the number of pixels required to display the derived fractal image will change, so S3 is executed; otherwise, it means that the number of pixels required to display the derived fractal image will not change, so S4 is executed.

[0078] In this regard, the desktop computer can count the pixels that have been used by the fractal points in the fractal image through a memo, and use the memo to detect whether the addition of a new fractal point will cause a change in the number of pixels required to display the derived fractal image. In addition, each pixel can be drawn only once, thereby improving the efficiency of drawing the fractal image.

[0079] It should also be understood that currently, to display a fractal image in the drawing area of ​​the screen, it is necessary to determine the pixel position of each fractal point on the fractal image in the drawing area. However, due to the limitation of the screen resolution, multiple fractal points in the fractal image will be mapped to the same pixel, which means that some pixels may be drawn repeatedly for multiple times.

[0080] Given this, since the memo already records usage statistics for each pixel in the drawing area, such as Figure 3 As shown, in Figure 2 On the basis of S5, displaying the target fractal graph in the drawing area according to the memo.

[0081] It can be understood that, according to the memo, it is determined which places in the memo are marked with used records, and then drawing is performed at the corresponding pixel positions. In this way, in the process of displaying the target fractal image in the drawing area, each pixel in it only needs to be drawn once. Since the number of repeated drawing operations is reduced, the drawing efficiency can be significantly improved.

[0082] In order to verify the technical effect of the fractal image drawing method provided by this embodiment, the initial drawing area is set to The actual drawing area is calculated based on the width and height ratio of the fractal image, which means that different fractals will have their own unique drawing areas due to different ratio factors. At the same time, in order to ensure that different methods produce the same random probability sequence, the random seed is fixed to 100 in this test.

[0083] In order to better demonstrate the drawing effects of the two-dimensional matrix memorandum method and the binary sorting tree memorandum method, four parameters are selected to correspond to a fractal drawing result. These four parameters are: step size, number of random iterations, number of pixels and drawing time. Figure 5 As shown in the figure, (10, 8010, 6344, 0.082) corresponding to the first pattern represent the step size, random iteration times, pixel count and drawing time respectively. Except for the step size which is input by the user, other parameters are automatically calculated by the desktop computer. This parameter setting can not only intuitively reflect the advantages and disadvantages of different methods, but also provide basic data for subsequent performance analysis.

[0084] In order to compare the drawing speed with the original random iteration method, the parameters of the original random iteration method are set to two parameters, namely: the number of random iterations and the drawing time. Figure 5 As shown in the figure, (3670, 0.04) corresponding to the first pattern represents the number of random iterations and the drawing time respectively. In this case, the number of random iterations is input by the user, while the drawing time is calculated and recorded in real time by a desktop computer. This design can clearly evaluate the difference between the two methods in drawing speed and effect. With the above settings, a variety of fractal images were used for verification. The fractal image used for verification is called the experimental fractal image here.

[0085] (1) The IFS code of the first experimental fractal image is shown in the following table:

[0086] For the above experimental fractal graph, Figure 4 As shown, the figure shows the fractal graph with different step lengths drawn using the two-dimensional matrix memorandum method.

[0087] like Figure 5 As shown, the figure shows the fractal graph drawn under different step length control using the binary sort tree memorandum method.

[0088] like Figure 6 As shown, the figure shows a fractal graph drawn with different numbers of iterations using the random iteration method.

[0089] Depend on Figure 4 , Figure 5 and Figure 6 It is not difficult to see that, when the number of random iterations is the same, the drawing time of each drawing method is as shown in the following table:

[0090] (2) The IFS code of the second experimental fractal image is shown in the following table:

[0091] like Figure 7 As shown, the figure shows the fractal graph with different step lengths drawn using the two-dimensional matrix memorandum method.

[0092] like Figure 8As shown, the figure shows the fractal graph drawn under different step length control using the binary sort tree memorandum method.

[0093] like Fig. 9 As shown, the figure shows the fractal plotting of the random iterative method at different numbers of iterations.

[0094] Depend on Figure 7 , Figure 8 and Fig. 9 It is not difficult to see that the time taken to draw the second experimental fractal image using three different methods with the same clarity is shown in the following table:

[0095] It is not difficult to see from the experimental results that with the increase of step size, the designed two-dimensional matrix memorandum method and binary sorting tree method have significantly improved the speed of fractal drawing. Therefore, these two methods have good performance in optimizing algorithm efficiency.

[0096] It is important to note that these three methods use the same random seed, which means that they will produce the same random sequence in the random number generation process. This consistency results in the same random probability sequence generated under the same number of random iterations. Therefore, the drawn fractal images also maintain consistency in clarity and detail. This feature is of great significance for studying and comparing the effects of different algorithms, because it eliminates the interference caused by randomness, making the results more comparable and reliable.

[0097] Based on the same inventive concept as the fractal image drawing method provided in this embodiment, this embodiment also provides a fractal image drawing device, which includes at least one software function module that can be stored in the memory 21 or fixed in the electronic device in the form of software. The processor in the electronic device is used to execute the executable module stored in the memory 21. For example, the software function module and computer program included in the device. Please refer to Fig.10 , functionally speaking, the device may include: The fractal graph module 11 is used to iterate the current basic fractal graph for a preset number of times to obtain a derived fractal graph; A clarity module 12, used to obtain a first number of pixels required for displaying the derived fractal image; The clarity module 12 is further configured to use the derived fractal image as a new basic fractal image if the second number of pixels required to display the basic fractal image is less than the first number of pixels, and return to the step of iterating the current basic fractal image a preset number of times to obtain the derived fractal image; The clarity module 12 is further configured to use the derived fractal image as the target fractal image if the second number of pixels is equal to the first number of pixels.

[0098] In this embodiment, the fractal image module 11 is used to implement Figure 1 In step S1, the definition module 12 is used to implement Figure 1 Therefore, for the detailed description of each of the above steps, please refer to the specific implementation of the corresponding step, and this implementation will not be repeated.

[0099] In addition, since the invention concept is the same as that of the fractal image drawing method, the fractal image drawing device can also implement other steps or sub-steps of the method through the above modules.

[0100] Optionally, the clarity module 12 is further specifically configured to: Get the newly added fractal points from the basic fractal image to the derived fractal image; If no record of displayed fractal points is found in the memo, the fractal points are displayed in the drawing area of ​​the screen, wherein the memo records the fractal points of the basic fractal image that have been displayed; According to the display pattern of the derived fractal image in the drawing area, a first number of pixels required to display the derived fractal image is obtained.

[0101] Optionally, the memo is a two-dimensional matrix of the same size as the drawing area, and the clarity module 12 is further specifically used for: Map the fractal points into a two-dimensional matrix to obtain the array positions of the fractal points in the two-dimensional matrix; If the array position does not record a preset display mark, it is determined that the record of the fractal point being displayed has not been searched.

[0102] Optionally, the clarity module 12 is further specifically configured to: The fractal points are mapped into a two-dimensional matrix using the first mapping relationship to obtain the array positions of the fractal points in the two-dimensional matrix.

[0103] Optionally, the clarity module 12 is further specifically configured to: The generated exploration fractal graph, wherein the number of iterations of the exploration fractal graph is less than the number of generations required to obtain the target fractal graph; The scaling factor is obtained based on the size of the explored fractal image and the size of the drawing area; According to the scaling factor, a first mapping relationship is obtained.

[0104] Optionally, the memo is a binary tree converted from a two-dimensional matrix of the same size as the drawing area, and the clarity module 12 is further specifically used for: Map the fractal points into a two-dimensional matrix to obtain the array positions of the fractal points in the two-dimensional matrix; Convert array positions to binary tree index values; If the fractal point is not found in the binary tree by the index value, it is determined that the record of the fractal point that has not been found has been displayed.

[0105] Optionally, the array position is converted into an index value of a binary tree, and the clarity module 12 is further specifically used for: Use the length or width of the drawing area as the weight; The coordinate values ​​of the array positions are weighted according to the weights to obtain the index value of the binary tree.

[0106] Optionally, the clarity module is also used to: The target fractal graph is displayed in a drawing area according to the memo.

[0107] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0108] It should also be understood that if the above implementation is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.

[0109] Therefore, this embodiment further provides a storage medium, which is a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by a processor, the fractal image drawing method provided in this embodiment is implemented. Among them, the storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, etc., which can store program codes.

[0110] This embodiment provides an electronic device for implementing a fractal image drawing method. Fig.11 As shown, the electronic device may include a processor 22 and a memory 21. In addition, the memory 21 stores a computer program, and the processor implements the fractal image drawing method provided in this embodiment by reading and executing the computer program corresponding to the above implementation in the memory 21.

[0111] Continue to see Fig.11The electronic device further includes a communication unit 23. The memory 21, the processor 22 and the communication unit 23 are electrically connected to each other directly or indirectly through a system bus 24 to achieve data transmission or interaction.

[0112] The memory 21 may be an information recording device based on any electronic, magnetic, optical or other physical principle, used to record execution instructions, data, etc. In some embodiments, the memory 21 may be, but is not limited to, a volatile memory, a non-volatile memory, a storage drive, etc.

[0113] In some embodiments, the volatile memory may be a random access memory (RAM); in some embodiments, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), a flash memory, etc.; in some embodiments, the storage drive may be a disk drive, a solid-state drive, any type of storage disk (such as a CD, a DVD, etc.), or a similar storage medium, or a combination thereof, etc.

[0114] The communication unit 23 is used to send and receive data through a network. In some embodiments, the network may include a wired network, a wireless network, a fiber optic network, a telecommunication network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, or a near field communication (NFC) network, or any combination thereof. In some embodiments, the network may include one or more network access points. For example, the network may include a wired or wireless network access point, such as a base station and / or a network switching node, and one or more components of the service request processing system may be connected to the network through the access point to exchange data and / or information.

[0115] The processor 22 may be an integrated circuit chip with signal processing capability, and the processor may include one or more processing cores (e.g., a single-core processor or a multi-core processor). By way of example only, the processor may include a central processing unit (CPU), an application specific integrated circuit (ASIC), an application specific instruction set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC), or a microprocessor, or any combination thereof.

[0116] Understandably, Fig.11The structure shown is for illustration only. The electronic device may also have Fig.11 More or fewer components than shown, or with Fig.11 Different configurations are shown. Fig.11 The components shown may be implemented in hardware, software or a combination thereof.

[0117] It should be understood that the apparatus and method disclosed in the above-mentioned embodiments can also be implemented in other ways. The apparatus embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the apparatus, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0118] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A fractal image drawing method, characterized in that: The method comprises: Iterate the current basic fractal graph for a preset number of times to obtain a derived fractal graph; Determining whether a number of pixels required to display the derived fractal image will change compared to the current base fractal image; If there is a change, the derived fractal graph is used as a new basic fractal graph, and the process returns to the step of iterating the current basic fractal graph a preset number of times to obtain a derived fractal graph; If no change occurs, the derived fractal graph is used as the target fractal graph.

2. The fractal graph drawing method according to claim 1, characterized in that: The derived fractal image is obtained by growing the current basic fractal image; and judging whether the number of pixels required to display the derived fractal image changes compared with the current basic fractal image, including: Obtaining newly added fractal points generated by the derived fractal graph; Determining a target position of the newly added fractal point in a memo, wherein the memo is used to record usage statistics of each pixel in a drawing area; If the target position does not mark a record that has been used, determining that the number of pixels required to display the derived fractal image will change; If the target position is marked with a record that has been used, it is determined that the number of pixels required to display the derived fractal image will not change.

3. The fractal image drawing method according to claim 2, characterized in that: The memo is a two-dimensional matrix of the same size as the drawing area, and determining the target position of the newly added fractal point in the memo includes: Acquire a first mapping relationship between the derived fractal image and the two-dimensional matrix; Mapping the position of the newly added fractal point in the derived fractal graph to an array position in the two-dimensional matrix by using a first mapping relationship; The array position is determined as the target position of the newly added fractal point in the memo.

4. The fractal image drawing method according to claim 3, characterized in that: The first mapping relationship between the derived fractal image and the two-dimensional matrix is ​​obtained: generating an exploration fractal graph, wherein the number of iterations of the exploration fractal graph is less than the number of generations required to obtain the target fractal graph; Obtaining a scaling factor according to the size of the exploration fractal image and the size of the drawing area; The first mapping relationship is obtained according to the scaling factor.

5. The fractal image drawing method according to claim 2, characterized in that: The memo is a binary tree converted from a two-dimensional matrix of the same size as the drawing area, and determining the target position of the newly added fractal point in the memo includes: Mapping the position of the newly added fractal point in the derived fractal graph to the two-dimensional matrix to obtain the array position of the newly added fractal point in the two-dimensional matrix; Converting the array position to an index value of the binary tree; The index value is determined as the target position of the newly added fractal point in the memo.

6. The fractal image drawing method according to claim 5, characterized in that: Converting the array position to an index value of the binary tree includes: Taking the length or width of the drawing area as a weight; The coordinate values ​​of the array positions are weighted according to the weights to obtain index values ​​of the binary tree.

7. The fractal image drawing method according to claim 2, characterized in that: The method further comprises: The target fractal graph is displayed in a drawing area according to the memo.

8. A fractal image drawing device, characterized in that: The device comprises: A fractal graph module, used to iterate the current basic fractal graph for a preset number of times to obtain a derived fractal graph; A clarity module, for determining whether the number of pixels required to display the derived fractal image will change compared to the current base fractal image; The clarity module is further configured to use the derived fractal image as a new basic fractal image if there is a change, and return to the step of iterating the current basic fractal image a preset number of times to obtain the derived fractal image; The clarity module is further configured to use the derived fractal graph as a target fractal graph if no change occurs.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the fractal image drawing method according to any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the fractal image drawing method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Computer fractal image generation method

    CN106504296A

  • Rapid fractal graph drawing method and system, user equipment and storage medium

    CN108846883A

  • Adaptive fractal drawing method, device and system and storage medium

    CN108921917A

  • Method for realizing fractal graph drawing through compression, equipment thereof, system and storage medium

    CN108961351A

  • Fractal information hiding / recovering method and system based on local microdomain variable precision

    CN114065245A

Cited By

  • Optical lens pattern generation method and system based on fractal iteration

    CN121414879A

  • A fractal iteration-based optical lens pattern generation method and system

    CN121414879B

  • Invariant fractal graph generation method and device, terminal equipment and storage medium

    CN121437662A

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

    CN121437662B